查询一个字段不为空的数据,怎么查
答案:2 悬赏:70 手机版
解决时间 2021-12-20 11:22
- 提问者网友:世勋超人
- 2021-12-20 01:08
查询一个字段不为空的数据,怎么查
最佳答案
- 五星知识达人网友:你哪知我潦倒为你
- 2021-12-20 01:38
--计算为null的个数 select count(*) from table where address is null --计算长度为0的个数 select count(*) from table where address='' --计算为null或长度为0的个数 select count(*) from table where address='' or address is null
全部回答
- 1楼网友:梦中风几里
- 2021-12-20 02:36
sql的isnull函数 --使用指定的替换值替换 null。
语法
isnull ( check_expression , replacement_value )
参数
check_expression 将被检查是否为 null的表达式。如果不为null,这直接返回 该值,也就是 check_expression 这个表达式。如果为空这个直接返回 replacement_value这个表达的内容。。。。check_expression 可以是任何类型的。
replacement_value
在 check_expression 为 null时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。
返回类型
返回与 check_expression 相同的类型。
注释
如果 check_expression 不为 null,那么返回该表达式的值;否则返回 replacement_value
示例:
select id,isnull(grade,0) from 表名--当grade为null时会被替换成0 ,不为null时会返回原有的值
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯