首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

not in 与 left join 的结果不同,可能是什么原因哦,解决马上给分解决思路

2012-01-30 
not in 与 left join 的结果不同,可能是什么原因哦,解决马上给分select*fromawhereidnotin(selectdistinct

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值?

热点排行
Bad Request.