第一个查询的where条件是:某列=一个空格,当然有结果返回
第二个查询的where条件是:某列=null, 对这种查询条件,无论如何都不会有结果返回,如果查询语句改成
select count(*) from po_dtl where decode(length(corp),10,'',corp) is null;那就可以

解决方案 »

  1.   

    语法不对,  where colname = ''是什么也取不出来的对应的语法应该是 where colname is null
      

  2.   

    SQL> select * from test1 where ''='';no rows selectedSQL> select * from test1 where '' is null;        ID ZYZ1       ZYZ2               P1         P2
    ---------- ---------- ---------- ---------- ----------
             1 zyz1       zyz2                1          2
             2 zyz11      zyz21              11         22
    SQL> select count(*) from test1 where decode(length(zyz1),4,'',zyz1) = '';  COUNT(*)
    ----------
             0
    SQL> select count(*) from test1 where decode(length(zyz1),4,'',zyz1) is null;  COUNT(*)
    ----------
             1
    明白了吧!!!
      

  3.   

    再問一下,在oracle中''就是null嗎?在sql server 中select * from table_name where column1_name = '' 
    是可以取到值的
      

  4.   

    1、有两种NULL。第一种NULL,是做为值来赋给其它变量的。如:A :=NULL。此时,NULL与 ''(两个连续的单引号)等价。第二种NULL,是做为关系操作符用的。如: IS NULL 和 IS NOT NULL。在这两个关系操作符中,NULL是不能用 '' 代替的。
    2、对于一个变量的值做判断时,如果变量为空值,则除了 IS NULL 和 IS NOT NULL 两种判断外,其它判断(如 =,>,<等)的结果都是假。