日期:2014-05-18  浏览次数:20669 次

not in 与 left join 的结果不同,可能是什么原因哦,解决马上给分
select   *   from   a   where   id   not   in   (select   distinct   id   from   b)
返回空集
select   *   from   a   left   join   b   on   a.id=b.id   where   b.id   is   null
返回很多

有点迷惑,还没找到原因,大虾给指点下啊


------解决方案--------------------
select * from a where id not in (select distinct id from b)
改成:
select * from a where id not in (select distinct id from b WHERE id IS NOT NULL)

------解决方案--------------------
a表或b表中的id有為null值?