网上搜了很多内容,大家之前的意见多是这样的
select ifnull(field,0) from table where .... 或 select coalesce(field,0) from table where ...
这样的,但因为我的查询是条件查询,结果集都是空的,并不是某一条记录的某个字段为空,所以 改写成如下形式,就ok了
select ifnull((select id from table where ....),0) 这样的就okay了(其实是个嵌套查询)