select * from table
where
field1 is not null and field2 is not null and field3 is not null and ...........and field9 is not null
查询这些字段都不为空的sql
我觉得好像也可以这样写:select field1,field2,.......,field8,field9 from table
1楼说的那个nvl(b,0) 函数,是若B字段存在null,则补0的意思。。。。
如:select a,nvl(b,0) from table若不加nvl(b,0),则无法查询出B字段null值的数据
所以我觉得第二种那写法也能查出来
没用的,必须做一次全表扫描,select * from table
where
field1 is not null and field2 is not null and field3 is not null and ...........and field9 is not null 虽然慢,但也是没办法的事,除非你事先为所有列都建上索引,再用
select field1,field2,field3,field4,field5,field6,field7,field8,field9 from table t order by 1,2,3,4,5,6,7,8,9 desc 这样就能把有值的数据排到前面
http://zhidao.baidu.com/question/176745471.html
http://zhidao.baidu.com/question/302266912.html
http://zhidao.baidu.com/question/302073985.html
http://zhidao.baidu.com/question/167921928.html
希望是你要找的!
select * from (select f1||f2||...... as col
from table2 ) t where t.col is not null
效率没试过 你可以试试