刚发现的,请大家不要运行下面语句,看得出的结果应该是什么?为什么结果是那样?
create table a(ss varchar(10))
goinsert into a
select 'a'
union all
select 'b'
union all
select 'c'
union all
select 'd'create table b(ss varchar(10))
goinsert into b
select 'b'
union all
select 'c'
union all
select 'd'
union all
select 'e'
union all
select nullselect * from a
where ss not in(select ss from b)

解决方案 »

  1.   

    问题还是出在这个 null 上..
      

  2.   

    你理解了 and 与or 的关系就容易理解这个现象了
      

  3.   

    在默认情况下 NULL和任何值比较都为空 
      

  4.   

    从理论上来说,结果应该有两个值:a和null,正因为包括了null,null不代表任何值,所以包含了null的返回记录也就不返回任何记录了
      

  5.   

    把 条件分成 and 
    a<> 1 and a <>2 and a<>null --这个为假,条件永远为假所以没有
      

  6.   

    http://topic.csdn.net/u/20100826/18/7b81012a-b5c4-48b1-b5d1-40a92f3e0388.htmlhttp://topic.csdn.net/u/20100523/16/3390EDEA-E0B2-4114-A078-938DBC8296BB.html
      

  7.   

    空表b中有nullnot in null不知道得到啥,所以为空
      

  8.   

    也就是说,b表中的null不知道是什么东西,也有可能是a,所以运行结果就干脆不显示了。。这样理解应该可以吧。
      

  9.   

    a<>b and a<>c and a<>d and a<>e and a<>null
    a<>null 为null
    true and null 为null
    where 视null为false
      

  10.   

    not in null  是个什么东东
      

  11.   

    如果要出现想要的结果,就把null用where条件过滤掉