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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章