select a.click_date,ifnull(b.count,0) as count_reg from ( select curdate() as click_date union all select date_sub(curdate(), interval 1 day) as click_date union all select date_sub(curdate(), interval 2 day) as click_date union all select date_sub(curdate(), interval 3 day) as click_date union all select date_sub(curdate(), interval 4 day) as click_date union all select date_sub(curdate(), interval 5 day) as click_date union all select date_sub(curdate(), interval 6 day) as click_date ) a left join ( select date(from_unixtime(reg_time)) as datetime, count(*) as count from member group by date(from_unixtime(reg_time)) ) b on a.click_date = b.datetime;
在企业网站建设中,如何用mysql统计最近7天数据?如上图,试试,
希望以上对你有所帮助。