select *  from abc where id not in(1,'')括号中写上''后没有任何数据显示出来,去掉''后就可以显示出来了,这是为什么啊?

解决方案 »

  1.   

    因为‘’(里面不是空格)相当于null,包含null的表达式都不成立,所以你查不到数据
    就相当于使用<>null也查询不到任何数据,必须使用is not null,
      

  2.   

    但where id not in(1,'') 意思不就是where id  is not 1  and id is not null吗
      

  3.   

    select * from abc where id not in(1,'');
    这个类似于
    select * from abc where id <>1 and id is not null;select * from abc where id not in(1,'');中的''就相当于null。
    当一个变量或常量和null比较时,只能够是xxx is not null 或xxx is null.
    而不能够用xx not in(null)等。
      

  4.   

    是的
    哪有字段这样写 id not in(null) ,oracle 里面是 id is not null or id is null
      

  5.   

    not in 非相关子查询中不能有NULL,可以改成相关子查询或existsNULL的注意点最少有20,30点,经常会有莫名的结果或错误,还是遇到就记下来吧
      

  6.   

    你把id改成nvl(id,0) 就会有神奇发现了,oracle里面的null,‘’,空值都表示不同的含义,注意了
      

  7.   

    首先,null是不能用等号和不等号来判断的
    id not in (1,'')相当于(id<>1 and id<>'')
    其中id<>''恒不成立,查询不会有结果
    id in (1,'')相当于 (id=1 or id='')
    id=''恒不成立,但两个条件中的连接词为or,id=1的记录能够正常输出
      

  8.   

    ''就是NULL,而不是空字符串,这点很迷惑人。
    估计问题就出在这里。
      

  9.   

    数据类型不同''是字符型,1是number
      

  10.   

    wildwave(狂浪),解释很清楚.在ORACLE中''相当于NULL的,在其他数据库可能又不一样了,遇到NULL时要特别小心.
      

  11.   

    oracle中null其实不表示完全为空,而是一个不确定的值,所以 null=null, null<>null ,null in null,null not in null 结果都是false。
      

  12.   

    select * from abc where id <>1;这样就足够了。null的也不回算在查询结果中 。null的列不管是比较等于或是不等于都是不成立的
      

  13.   

    NULL这东西只能注意呢!NULL和''在oracle中有时候不等价,有时候NULL像是字符类型,但是有时候又是无类型的。