日期:2014-05-19  浏览次数:20763 次

求一个SQL查询语句
a表里面有2个字段

    aa       bb
      1
      2

b表里面有一个字段
      aa
        1
        2
        3
        4

select   aa   from   b   where   not   in(select   aa   from   a)

这样没有错,但是

select   aa   from   b   where   not   in(select   bb   from   a)

这样就没有返回值了,,大家帮忙看看啊,


------解决方案--------------------
null 是一个不确定的值.有时候会导致查询的结果不确定.
你可以这样:
select aa from b where not in(select isnull(bb, ' ') as col1 from a)