下面有两个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值排除在外