T-SQL not in 遇到 null 暗含的陷阱
Posted lee576
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了T-SQL not in 遇到 null 暗含的陷阱相关的知识,希望对你有一定的参考价值。
下面有两个T-SQL,乍看之下以为是等效的,实际却不是这样
SELECT orderid1 ,
LocalCost ,
supplyGoodsName ,
buyersgoodsid ,
JSitId ,
GSitId
FROM csc_result WITH ( NOLOCK )
WHERE [level] > 0
AND orderid1 LIKE ‘618464266%‘
AND ( supplygoodsid NOT IN ( 1085317, 1112957 ) )
SELECT orderid1,
LocalCost ,
supplyGoodsName ,
buyersgoodsid ,
JSitId ,
GSitId
FROM csc_result WITH ( NOLOCK )
WHERE [level] > 0
AND orderid1 LIKE ‘618464266%‘
AND (supplygoodsid NOT IN ( 1085317,
1112957 )
OR SupplyGoodsId IS NULL)
可见not in并不能把null值排除在外
以上是关于T-SQL not in 遇到 null 暗含的陷阱的主要内容,如果未能解决你的问题,请参考以下文章
windows 中使用hbase 异常:java.io.IOException: Could not locate executable nullinwinutils.exe in the Ha