运行sql时出现多个空值,如何去除

如题所述

1、创建测试表,

create table test_null(work_no VARCHAR(20), chinese_name varchar2(20), department_name varchar2(20), department_id varchar2(20), fee varchar2(20));

2、插入测试数据

insert into test_null values(null,null,null,null,'5.00');

insert into test_null values(null,null,null,null,'17.00');

insert into test_null values(null,null,null,null,'29.50');

insert into test_null values(null,null,null,null,'52.00');

insert into test_null values(321269,'梁XX','外销','WX','5.00');

3、查询原始表的记录,select t.*, rowid from test_null t ,有很多字段值为空的记录,

4、编写sql,限定条件,过滤掉字段为null的记录,

select t.*

  from test_null t

 where work_no is not null

   and chinese_name is not null

   and department_name is not null

   and department_id is not null,

温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-11-25
在select语句的后面加上条件 where work_no is not null or where chinese_name is not null or department_name is not null or department_id is not null;那么就可以将这四项只要有一个出现空值的数据不显示本回答被网友采纳
第2个回答  2014-06-16

你是要删除null的数据还是忽略不查null的数据?

要是忽略:  select * from 表名 where work_no is not null 

看你的表结构,work_no 应该是主键,最好将这个属性设置不可为空

第3个回答  2014-06-16
delete 表
where work_no is null and Chinese_name is null and deparement_name is null and department_id is null
相似回答