表1: test001
select * from test001
表2:test002
select * from test002
执行语句:
select * from test002 where id not in(select id from test001)
居然没有结果?
原因:因为test001表中有id为空
解决方法:
方法一:
select * from test002 where id not in(select id from test001 where id is not null)
方法二:
select * from test002 a where not exists (select 1 from test001 b where b.id=a.id)