我写了两条语句select count(1) from t_jc_xzxk_shouli t where byzdb is null;
select count(1) from t_jc_xzxk_shouli t where byzdb <> '1';

前者能查到数据727936而后者却只能查到331条数据

难道null和<>'1'有这么大的区别?不明白,求赐教

解决方案 »

  1.   

    byzdb有几种值呢?除了不等于'1'的,还有什么值?
    你可以执行下面语句查一下byzdb有哪些值:
    select distinct byzdb from t_jc_xzxk_shouli t;
      

  2.   

    lz 你这问题问得 null 和 不等于'1' 等价吗?等价吗??等价吗???
      

  3.   

    在oracle中,空值和任意值做比较判断,得到的结果都是“否”
    SQL> select case when null <> 'a' then 'true' else 'false' end as result from dual;
     
    RESULT
    ------
    false
    SQL> select case when null > 'a' then 'true' else 'false' end as result from dual;
     
    RESULT
    ------
    false
    SQL> select case when null < 'a' then 'true' else 'false' end as result from dual;
     
    RESULT
    ------
    false
    SQL> select case when null = 'a' then 'true' else 'false' end as result from dual;
     
    RESULT
    ------
    false
      

  4.   

    也写过distinctSELECT distinct BYZDB
                      FROM t_jc_xzxk_shouli
                     group by  BYZDB值为以下三者:无
    null
    NULL
      

  5.   

    难道楼主这么问是t_jc_xzxk_shouli表里byzdb字段除了'1'就值null?
     
      

  6.   

    对的,只有无
    null
    NULL
    这三个值
      

  7.   

    select count(1) from t_jc_xzxk_shouli t where byzdb is null;
    这个查出来的是byzdb字段为空的
    select count(1) from t_jc_xzxk_shouli t where byzdb <> '1';
    这个查出来的是byzdb字段 不为空 且 不等于 1 的在用=和<>做判断的时候,隐含一个条件is not null
    这个两个查询的意义完全不同啊,数值一样才叫凑巧了呢
      

  8.   

    null  和  NULL 都是具体的值无  才是真正的null