mysql空数据的处理

1.统计分析时,统计值为null则转为0

//统计婚姻接口调用次数
select count ,(zsj/count) as pjdysj
from(
-- 实时调用量 评论返回时间差(取平均值)
select count(1) as count ,ifnull(sum(TIMESTAMPDIFF(day,a.DTJRQ,b.RKSJ)),0) as zsj
from dsr_hc_bm a ,dsr_hc_hy b
where a.dbmbh='dsr_hc_hy'
and a.DTJRQ like CONCAT('2019','%')
and b.RKSJ like CONCAT('2019','%')
and a.dhcid = b.hyhcid
)c

2.查询字段值为空的数据:空值不一定等于空字符

select * from sr_main where (mhzsfz is null  or mhzsfz = '');

原文地址:https://www.cnblogs.com/tongcc/p/12222298.html