select * from table where name=null
是这样吗?

解决方案 »

  1.   


    select * from table where name is null
      

  2.   

    TD004 TD010
    3INKSX0636M 270.00000000
    3INKSX0541C 270.00000000
    3INKSX0004M 270.00000000
    3INKBTT307W 480.00000000
    3INKBTL0288 160.00000000
    3INKBTCG11M 480.00000000
    3INKBT0229D 230.00000000
    3INKBT0229D 240.000000003CTSLB00C50 72.00000000 例如:想要的数据同一个品号只把有不同的单价显示出来
    3CTSLB00C50 80.00000000 想要的数据同一个品号只把有不同的单价显示出来怎么写呢?
      

  3.   

    select * from table where name is null
      

  4.   

    只有在UPDATE的时候,才能使用name=null;其他时候都是name is null或name is not null来进行判断。
      

  5.   

    select * from table where name is null or name=''
      

  6.   


    select * from table where isnull(name,'')=''
      

  7.   


    isnull  对于性能效率(索引等)也有所影响,也要慎用。
      

  8.   

    注意SQL中''和Null区别
    '' 表示空字符串
    null表示什么都没有,什么都不是
    判断'' 用  ='' 或 <>'' , 而null 用is null 或is not null,字段中如果出现null 会对查询语句造成影响有可能导致索引失效,所以字段中尽量不要出现null ,用'' 或其他字符代替 ,另一种观点:null不代表空字符串,代表表示什么都没有,什么都不是,可以出现在任意类型字段里面(int,decimal,varchar 等等都可以是null),''只能在varchar,char类型里面出现
    ''的查询条件要写成 where 字段名='' 
    NULL的查询条件要写成 where 字段名 is  (not) null
      

  9.   

    select * from table where name is null
      

  10.   

    select * from table where name is null
      

  11.   


    正解08 和05 不一样  如若单纯的 判断is null  可能会漏掉