in 条件中包含null值查询异常
create table A
(
col1 varchar(20)
)
insert into A select null
insert into A select 'A'
insert into A select 'B'
create table B
(
col1 varchar(20)
)
insert into B select 'A'
insert into B select 'B'
insert into B select 'C'
--查询异常
select *from b where col1 not in (select col1 from A)
查看“执行计划”谓词加了b.col1 is null or a.col1 is null or a.col1=b.col1
我想这个肯定是出现异常的原因所在的,请高手解释一下,谢谢
--查询正常
select *from B t1 where not exists (select col1 from A where col1=t1.col1 )