SQL Server null??????
???????????? ???????[ 2016/3/9 11:12:55 ] ?????????????
????3.1 Not In??null
?????????????????У?where????????not in???????????where??????????OrderStatus not in ('Active'??'InActive')????????????????а???orderstatus?'Not Active'??'NULL'?????е??????
????select * from orders where OrderStatus not in ('Active'??'InActive')
???????????У???OrderStatus?null??? ?where???????where null <>'Active' AND null<>'InActive'?????????????н????????????null??????where???ж???????null????????в?????????????С?????OrderStatus?'Not Active'???????where?????true????????????????????С?
????????????????????С?
?????????in??null???????????
????3.2 Not exists??null
?????????????????????????а???orderstatus?'Not Active'??'NULL'?????е???????????Not exists??
?????????????У??????????OrderStatus='Active' or OrderStatus='InActive???У???????????not exists??????????????????μ???????????????С?
????SELECT *
????FROM orders AS o1
????WHERE NOT EXISTS(
????SELECT *
????FROM orders AS o2
????WHERE o1.OrderStatus = o2.OrderStatus
????AND ( o2.OrderStatus = 'Active'
????OR o2.OrderStatus = 'InActive'
????));
????????????????????????д??????????????
????select * from orders as o2 where o1.OrderStatus=o2.OrderStatus and (o2.OrderStatus='Active' or o2.OrderStatus='InActive' ))
??????д???
????SELECT *
????FROM orders AS o2
????INNER JOIN orders o1 ON o1.OrderStatus = o2.OrderStatus
????AND ( o2.OrderStatus = 'Active'
????OR o2.OrderStatus = 'InActive'
????);
????????????????
?????????????????????
????????????????not exists????orders???в?????????????????У?????????orders???????????????е??з???true????????false????д?????????????unknown?????????
????????????????orderID?3??4???в??????????????У????not exists?ж??true????orderID?1??2??????????????????????У?????not exists?ж??false???????where??“????true?????false??null”??????????orderID?3??4??????????????С?
?????????exists??null???????????
????3.3 Not in??Not exists??????
????not in??????????????????????????????true|false|unknow??????????
????not exsits?ж??????????????????????????????????????unknown?????????????not in?????not exists?????true??false????????????
???????
?????????????null?????????е???壬?????SQL?????????????null?????????????????????дSQL??????????????????????д??????????null????????????????????????????
??????
???·???
??????????????????
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