读书人

oracle 不等于空判断无效,该怎么解决

发布时间: 2012-04-09 13:41:25 作者: rapoo

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、‘’空格不是空值。

读书人网 >oracle

热点推荐