
select count(0) from tps_uw_detail where trim(coreContNo)=''###1736
select count(0) from tps_uw_detail where coreContNo is null###735
select count(0) from tps_uw_detail where (coreContNo is null or trim(coreContNo)='')##2471
=''就是存的空字符串;is null 就是默认的。
由于是后来新加的字段,默认为null,所以历史数据都为null。表中加上这个字段后,再落库的数据就是空字符串了。
根据自己的需求选用脚本,第三个是适合我的。
2.SQL Server 查询某个字段为空,没有内容select * from 表名 where 字段名 = ''
3.SQL Server 查询某个字段为NULL
select * from 表名 where 字段名 is null
sql语句查询时,把查询为空的数据显示为零的步骤如下:
我们需要准备的材料分别有:电脑、sql查询器。
1、首先,打开sql查询器,连接上相应的数据库表,例如stu表。
2、点击“查询”按钮,输入:select `name`,IF(score is null, 0, score) from stu。
3、点击“运行”按钮,此时看到score字段为空的数据查出来是0。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)