select * from T_Fault where State = 3 and ID > 1001 and (Flag <> '1' and Flag is not null) order by ID

解决方案 »

  1.   

    select * from T_Fault where State = 3 and ID > 1001 and Flag is null order by ID
      

  2.   

    null和任何值比较都是null,所以查不出数据,既然只有 null 值和 1,则用 is null就行了.
      

  3.   

    --如果不单是1和null,则用
    select * from T_Fault where State = 3 and ID > 1001 and isnull(Flag,'0')<>'1' order by ID
      

  4.   

    select * 
    from T_Fault 
    where State = 3 and ID > 1001 and isnull(Flag,'') <> '1' 
    order by ID
      

  5.   

    同意,is null,就这样,简单明了