CREATE TABLE `connectionLog` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`serverTimeConnected` datetime NOT NULL,
`serverTimeDisconnected` datetime NOT NULL,
PRIMARY KEY (`ID`)
);
通过这个查询,我得到了 serverTimeConnected 在一小时内的所有 ID。
SELECT HOUR( `serverTimeConnected`) as STUNDE,
count(`ID`) as HITS
FROM `connectionLog`
GROUP BY HOUR( `serverTimeConnected`)
但我需要 serverTimeConnected 和 serverTimeDisconnected 之间的所有 ID。
ID serverTimeConnected serverTimeDisconnected
1 10:00:00 10:10:00
2 10:00:00 11:10:00
3 10:00:00 12:10:00
我需要一个结果——比如
STUNDE HITS
10, 3
11, 2
12, 1