当我有一个查询来检查uniqueidentifer具有空值的表中是否不存在类型的列时,我不会得到任何结果。如果子查询不返回空值,则它工作正常,并且仅在使用not in.
我知道我可以只not null检查我的子查询,但我很好奇为什么这不起作用。
查询示例:
select a.guid from tableA a where a.guid not in (select b.guid from tableB AS b)
Run Code Online (Sandbox Code Playgroud)
工作测试:
select 1 where newid() not in (select newid())
Run Code Online (Sandbox Code Playgroud)
破碎测试:
select 1 where newid() not in (select null)
Run Code Online (Sandbox Code Playgroud)