elect dd.eday as'日期',if(tp.c is null, 0, tp.c)as '访问量' from (
select 1 as eday union select 2 union select 3 union select 4 union select 5
union select 6 union select 7 union select 8 union select 9 union select 10
union select 11 union select 12 union select 13 union select 14 union select 15
union select 16 union select 17 union select 18 union select 19 union select 20
union select 21 union select 22 union select 23 union select 24 union select 25
union select 26 union select 27 union select 28 union select 29 union select 30
union select 31) dd
left join (
select DATE_FORMAT(rf.client_datetime, '%e') d , DATE_FORMAT(rf.client_datetime, '%Y%m%d')s, COUNT(*) c from api_flow_jnl rf
where rf.client_datetime>'2014-05-01'
and rf.client_datetime<'2014-05-31'
group by d) tp
on tp.d = dd.eday;
转载请注明:谷谷点程序 » mySQL 统计数据时,数据为空的显示为0