目前四个不同的表 单独查询求和每天的数据
请教如何合并查询四组不同数据每一天的和 首列按日期排序只取年月日
SELECT
DATE_FORMAT(createTime, '%Y-%m-%d') AS 日期,
count(*) AS 注册人次
FROM
tokenlog
WHERE createTime BETWEEN '2017-05-01' AND '2017-05-31'
GROUP BY
DATE_FORMAT(createTime, '%Y-%m-%d')
ORDER BY
createTime
===============================================
SELECT
DATE_FORMAT(logTime, '%Y-%m-%d') AS 日期,
count(*) AS 场次
FROM
sumelog
WHERE logTime BETWEEN '2017-05-01' AND '2017-05-31'
GROUP BY
DATE_FORMAT(logTime, '%Y-%m-%d')
ORDER BY
logTime
===============================================
SELECT
DATE_FORMAT(logTime, '%Y-%m-%d') AS 日期,
Sum(sumelog.consume) AS 消耗金币
FROM
sumelog
WHERE logTime BETWEEN '2017-05-01' AND '2017-05-31'
GROUP BY
DATE_FORMAT(logTime, '%Y-%m-%d')
ORDER BY
logTime
===============================================
SELECT
DATE_FORMAT(endTime, '%Y-%m-%d') AS 日期,
count(DISTINCT userId) AS 参加活动人次
FROM
game_u
WHERE endTime BETWEEN '2017-05-01' AND '2017-05-31'
GROUP BY
DATE_FORMAT(endTime, '%Y-%m-%d')
ORDER BY
endTime
要求最终显示结果如下
日期 注册人次 场次 消耗金币 参加活动人次
2017-05-01 8 2 2 8
2017-05-02 4 1 1 4
2017-05-03 16 8 8 16
2017-05-04 4 1 1 4
2017-05-05 20 10 10 20
mysql 注意是在不改表结构和类型的情况下