Oracle中查询某字段不为空的SQL语句怎么写

假设表A有id,info两个字段,我要查询这个表里面的所有info不为空的数据应该怎么写SQL?

sql中判断非空不能用等号,因为null在sql中被看作特殊符号,必须使用关键字 is和not

select * from A where info is not null

问题延展:不为空有2中种,不是空值 is not null 不是空格 <>""

温馨提示:内容为网友见解,仅供参考
第1个回答  2017-04-11
sql中判断非空不能用等号,因为null在sql中被看作特殊符号,必须使用关键字 is和not
select * from A where info is not null本回答被提问者采纳
第2个回答  2017-12-30
比如
insert into table a (a1,b1)values("a1",'');
对于这种情况,因为表里存的是'',其实是没有内容的,要查询这个字段,不能直接使用
select *
from a
where b1='';
sql中判断非空不能用等号,因为null在sql中被看作特殊符号,必须使用关键字 is和not
应该如此使用:
select * from A where b1 is null
或者:
select * from A where b1 is not null
第3个回答  2012-02-11
select id,info from 表名 where info is not null;
第4个回答  2012-02-10
select id,info from A where info is not null;
相似回答