今天用了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
今天用了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