因为‘’(里面不是空格)相当于null,包含null的表达式都不成立,所以你查不到数据 就相当于使用<>null也查询不到任何数据,必须使用is not null,
但where id not in(1,'') 意思不就是where id is not 1 and id is not null吗
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)等。
是的 哪有字段这样写 id not in(null) ,oracle 里面是 id is not null or id is null
not in 非相关子查询中不能有NULL,可以改成相关子查询或existsNULL的注意点最少有20,30点,经常会有莫名的结果或错误,还是遇到就记下来吧
就相当于使用<>null也查询不到任何数据,必须使用is not null,
这个类似于
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)等。
哪有字段这样写 id not in(null) ,oracle 里面是 id is not null or id is null
id not in (1,'')相当于(id<>1 and id<>'')
其中id<>''恒不成立,查询不会有结果
id in (1,'')相当于 (id=1 or id='')
id=''恒不成立,但两个条件中的连接词为or,id=1的记录能够正常输出
估计问题就出在这里。