個人收集的一些常用的sql查詢語句與函式

2021-04-25 10:52:00 字數 804 閱讀 4033

壹.語句

一、select from

1.distinct 去掉重覆記錄

2.where 條件,後接between, is null,like,in,exists

3.union 求並

4.group by

5.orader by desc

二、insert into values

三、delete from

四、update set

貳.函式

一、時間日期

1.day()

2.month()

3.year()

4.dateadd(datepart,number,date)

5.datediff(datepart,date1,date2)

6.datename(datepart,date)

7.getdate()

二、字串

1.ascii()

2.char()

3.lower()小寫

4.upper()大寫

5.str()

6.ltrim()去開頭空格

7.rtrim()去尾部空格

8.left()

9.right()

10.substring(str,n,m)去部分

11.charindex(sub,str)前為所查,後為全部,返回出現位置;類似:partindex(%%,str)

12.reverse()

13.replace(n1,n2,n3)n3替換n2

三、資料型別轉換

1.cast()

一些常用的SQL查詢語句

select alter table case when o.schema id is notnull then select name from sys.schemas where schema id o.schema id else end object name parent object i...

一些常用的正規表示式 個人收集

我特別容易忘記東西,寫下來備用 高手請繞道 1.的正則 bsrc s t r n s t r n s t r n s t r n s t r n 解釋 捕獲組的值為的src 2.a標籤正則 bhref s t r n s t r n s t r n s t r n s t r n 解釋 捕獲組的值為...

一些常用的sql(一)

在列名和別名之間放上as或者空格 select empno as employee number ename name,500 sal 12 annual salary from emp 用兩個豎線 把乙個或多個字串連起來 select ename annual salary is 500 sal ...