@
phpfpm #2
@
zzn #3
@
zzn #5
大佬们我最终写成了这样的到了我想要的结果 不知道有没有更好的办法
select temp.* from
(
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 6 DAY) as count_time FROM `test` WHERE `reg_time`<DATE_SUB(NOW(), INTERVAL 6 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 5 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 5 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 4 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 4 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 3 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 3 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 2 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 2 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count ,DATE_SUB(NOW(), INTERVAL 1 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 1 DAY)
UNION ALL
SELECT COUNT(`user_id`) as count , DATE_SUB(NOW(), INTERVAL 0 DAY) as count_time FROM `test` WHERE `reg_time`< DATE_SUB(NOW(), INTERVAL 0 DAY)
) as temp