Mysql Not in的问题

今天用了Mysql的not in,大致是

select * from A where A.id not in (select fid from B).

发现无论如何结果都是0条记录。

后来发现select fid from B里面有一条NULL值,查了资料才知道mysql 的not in里面如果有一个NULL值,将返回0条记录。

要解决这个问题需要把 select fid from B 变成

select fid from B where B.fid is not null

猜你喜欢

转载自kgdso.iteye.com/blog/1633231