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

sql 空值问题
表 table字段有(没个字段类型都是varchar2(20))
field1,field2,field3,field4,field5,field6,field7,field8,field9
  b 2 a3 1 2 s1f 1
  1s 2 2 c 2 2 3 3 2
  0 1 3 3 fd df s

如何快速判断哪一条数据里面没有空值
即 field1,field2,……feeld9这几列中值都不为空的查询出来


------解决方案--------------------
SQL code

select *
from tb
where field1||field2||field3||field4||field5||field6||field7||field8||field9 is not null

------解决方案--------------------
select * from 表名
where field1 is not null
and field2 is not null
and field3 is not null
and field4 is not null
and field5 is not null
and field6 is not null
and field7 is not null
and field8 is not null
and field9 is not null
;

感觉这个方法有点笨拙,不知道大家有社么简单的方法?
------解决方案--------------------
2楼的不能用来判断是否都不为null
使用||,只要有一个不为null,则连接的结果都不为null
------解决方案--------------------
探讨

select * from 表名
where field1 is not null
and field2 is not null
and field3 is not null
and field4 is not null
and field5 is not null
and field6 is not null
and field7 is not null
and field8 ……