?????????????????????????????????Mysql??????select???????????????????
?????????????????????з????mysql?????????????????????SQL???Ч??????????????????where?е??????????????????????????????????????????????400???????????????????????????????????????????侹????40??????????????????????κ????????????????????sql?????Ч??????????????????????????????????30??SQL???????????????
????1????????????? where ????????!=??<>?????????????????????????????????????衣
????2?????????????????????????????裬??????????? where ?? order by ?漰???????????????
????3????????????? where ????ж???ν??? null ??ж???????????????????????????????????裬?磺
????select id from t where num is null
??????????num??????????0?????????num?????null???????????????
????select id from t where num=0
????4???????????? where ???????? or ?????????????????????????????????????????????裬?磺
????select id from t where num=10 or num=20
?????????????????
????select id from t where num=10
????union all
????select id from t where num=20
????5?????????????????????裺(??????e???)
????select id from t where name like ‘?c%’
??????????Ч??????????????????
????6??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
????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?????????? 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)
????14????????????????????????Ч??SQL?????????????????в?????????????????д?????????????SQL????????????????????????????????? sex??male??female?????????????????sex??????????????Ч?????????á?
????15?????????????????????????????????????? select ??Ч?????????????? insert ?? update ??Ч?????? insert ?? update ??п?????????????????????????????????????????????????????????????????ò??????6?????????????????Щ?????????????????????????? ?????
????16.?????????????? clustered ?????????У???? clustered ?????????е???????????????洢?????????????佫?????????????????????????????????????????????????????? clustered ?????????У?????????????????????????? clustered ??????
????17?????????????????Σ????????????????ξ???????????????????????????????????????????洢????????????????????????????????? ??????????????????????????????????????????????ι????
????18???????????? varchar/nvarchar ???? char/nchar ????????????δ洢???С?????????洢?????ζ???????????????????С???????????Ч????????Щ??
????19???κε?????????? select * from t ???t????????б????“*”??????????ò??????κ???Ρ?
????20??????????????????????????????????????????????????????????????????????????????
????21???????????????????????????????????????????
????22????????????????????????????????????Щ???????Ч?????磬?????????????????????е?????????????????????????????????? ????????
????23????????????????????????????????????????????? select into ???? create table???????????? log ???????????????????????????????????????????create table?????insert??
????24???????????????????洢?????????????е???????????????? truncate table ????? drop table ?????????????????????????????
????25??????????????α?????α??Ч????????α?????????????1???У???????????д??
????26?????????α???????????????????????????????????????????????????????????????Ч??
????27???????????????α??????????á???С?????????? FAST_FORWARD?α????????????????д??????????????????????ü?????????????????????????????а???“???”????????????????α???е????????????? ????????????α???????????????????????????£?????????????Ч?????á?
????28???????е?洢???????????????????? SET NOCOUNT ON ???????????? SET NOCOUNT OFF ??????????д洢???????????????????????????? DONE_IN_PROC ?????
????29????????????????????????????????????????????????????????????
????30???????????????????????????????????
??????????mysql???????????????Щ???????????????????????????????????mysql????????.