?????SQL?????????????????????????
???????????? ???????[ 2017/3/10 11:17:58 ] ????????????? SQL
????1.???????????????????????????裬??????????? where ?? order by ?漰???????????????
????2.??????????? where ????ж???????? null ??ж???????????????????????????????????裬?磺
????select id from t where num is null
?????ò????????????NULL???????????? NOT NULL????????.
??????????????????????????????? NULL??????????ò?????NULL??
?????????? NULL ???????????磺char(100) ???????ν?????????????? ?????????????NULL??????????????????? 100????????????????varchar?????????Σ? null ???????
??????????num??????????0?????????num?????null???????????????
????select id from t where num = 0
????3.??????????? where ???????? != ?? <> ?????????????????????????????????????衣 4.??????????? where ???????? or ???????????????????????????????????????????????????????????????????????????裬?磺
????select id from t where num=10 or Name = 'admin'
?????????????????
????union all
????select id from t where Name = 'admin'
????5.in ?? not in ???????????????????裬?磺
????select id from t where num in(1??2??3)
??????????????????????? between ????? in ???
????select id from t where num between 1 and 3
???????????? exists ???? in ???????????
????select num from a where num in(select num from b)
???????????????滻??
????select num from a where exists(select 1 from b where num=a.num)
????6.???????????????????裺
????select id from t where name like ‘%abc%’
??????????Ч??????????????????
????7.????? where ???????ò???????????????衣???SQL??????????????????????????????????????????????????????????????????????????????? ????????????????????????????????????δ??????????????????????????????????佫?????????裺
????select id from t where num = @num
????????????????????????
????select id from t with(index(??????)) where num = @num
????8.??????????? where ????ж???ν??б????????????????????????????????????????衣?磺
????select id from t where num/2 = 100
????????:
????select id from t where num = 100*2
????9.???????????where????ж???ν??к????????????????????????????????????????衣?磺
????select id from t where substring(name??1??3) = ’abc’ -–name??abc?????id
????select id from t where datediff(day??createdate??’2005-11-30′) = 0 -–‘2005-11-30’ --?????id
????????:
????select id from t where name like 'abc%'
????select id from t where createdate >= '2005-11-30' and createdate < '2005-12-1'
????10.????? where ????е?“=”?????к?????????????????????????????????????????????????????
????11.????????????????????????????????????????????????????????????е????????????????????????????????????????????????????????????????????????????????????????
????12.???д?Щ??????????????????????????????
????select col1??col2 into #t from t where 1=0
????????????????κν?????????????????????????????????
????create table #t(…)
????13.Update ???????????1??2????Σ????Update?????Σ??????????????????????????????????????????????
????14.???????????????????X?????????????JOIN?????????JOIN?????????????????????
????15.select count(*) from table???????????κ???????count???????????裬????????κ???????壬????????????
????16.???????????????????????????????????? select ??Ч?????????????? insert ?? update ??Ч?????? insert ?? update ??п?????????????????????????????????????????????????????????????????ò??????6?????????????????Щ?????????????????????????? ?????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11