有一个表
name code 
王    null
李    null
张    1
邓    1
梁    2我要查询code不等于2的值,我用select * from 表1 where code!=2怎么查出来只有张,邓,二行,王李这二行不出来也

解决方案 »

  1.   

    select * from 表1 where code<>2 and code is not null
      

  2.   

    select * from 表1 where code<>2 or code is null
      

  3.   

    select * from 表1 where code not in (select select * from 表1 where code<>2)
      

  4.   

    select * from 表名 where isnull(code,0)!=2
      

  5.   

    select * from 表1 where code is null or code <> 2 
      

  6.   

    我要的是
    王    null
    李    null
    张    1
    邓    1
      

  7.   

    select * from 表1 where code<>2 or code is null
      

  8.   

    select * from 表名 where isnull(code,0)!=2
      

  9.   

    select * from 表1 where code not in (select select * from 表1 where code<>2) and ...
    或者
    select * from 表1 where (code<>2 or code is null) and ....