日期:2014-05-17  浏览次数:21946 次

oracle 不等于空判断无效
select * from CERTSTORAGE t where t.saleperson!=''
我数据中有一条saleperson有值,但是始终查询不到一条记录

------解决方案--------------------
不等于是<>
------解决方案--------------------
select * from CERTSTORAGE t where t.saleperson is not null
------解决方案--------------------
不等!=和<>都可以
select * from CERTSTORAGE t where t.saleperson is not null or trim(t.saleperson)=''
------解决方案--------------------
空值没有大小,自然不能进行大于、小于、等于运算。
而只能进行is null,is not null的判定
------解决方案--------------------
select * from CERTSTORAGE t where t.saleperson is not null
------解决方案--------------------
空字符就是null了 

select * from CERTSTORAGE t where t.saleperson is not null 这样也查不到?
------解决方案--------------------
不等于 != 倒也可以,但按lz的意思 应该写成is not null
------解决方案--------------------
is not null 不为空
is null 为空
------解决方案--------------------
我也遇到过这样的情况,你把* 去掉。写具体的列看看。
我上次select count(*) from table_name where hp is null,就是显示的0
后来改成select count(id) from table_name where hp is null,就显示1了!
------解决方案--------------------
1、is null 为空;
2、is not null 不为空;
3、‘’空格不是空值。