关于sqlserver 中 not in 问题

来源:互联网 发布:burberry围巾 知乎 编辑:程序博客网 时间:2024/04/30 19:39

 SQLServer 中在使用 not in A 语句的时候 A 集合中不能有 NULL,而使用 in A 的时候 A 集合中可以有 NULL。太让人恶心了,让我困惑了大半天!!

另外,听说not in 的效率不高,最好是先根据字段id生成集合,在从中获取其他值

如:

select cc.id,cc.value from (select aa.*,bb.id as tempcolum from aa left join bb on aa.id=bb.id) as cc where cc.tempcolum is null

原创粉丝点击