sql判断字段是否为空

如题所述

1、创建测试表,

create table test_null(id varchar2(20),value varchar2(20));

2、插入测试数据;

insert into test_null values(1,'123');

insert into test_null values(2,'abc');

insert into test_null values(3,'');

insert into test_null values(4,'456');

3、查询表中全量数据;select t.*, rowid from test_null t;

4、编写语句,查询表中value为空的记录;

   select t.*, rowid from test_null t where value is null;

温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-11-26
啥意思?

sqlserver有isnull()函数的
select * from 表 where isnull(字段,‘’)=‘’就是空
select * from 表 where isnull(字段,‘’)<>‘’就不为空本回答被提问者和网友采纳
第2个回答  2018-08-02
sql server 中使用 is null 或 is not null 来处理列的空值。

语法为:
列名 is null (字段为空返回true ,不为空返回 false)
列名 is not null (字段为空返回false,不为空返回 true)

例:
select case when a is null then 1 else 0 end from aaa

语法大意:如果a列 为空显示1,不为空显示0
第3个回答  2014-02-14
ISNULL(字段,'')=''即为空
len(ISNULL(字段,''))>0不为空
select * from 表 where 字段 is null "找出字段为空的数据"
select * from 表 where 字段 is not null "找出字段不为空的数据"
第4个回答  2014-02-13
查数据表中,tb_name字段为null的语句
select * from tablename where tb_name is null

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网