所以我有这个查询:
SELECT ABS(
TIMESTAMPDIFF(MINUTE, NOW(),
(SELECT MAX(`Time`) FROM ddHistorical WHERE ID = '5')
)
)
我想在我的数据库中的每个 ID 上运行它,我该怎么做?
所以我有这个查询:
SELECT ABS(
TIMESTAMPDIFF(MINUTE, NOW(),
(SELECT MAX(`Time`) FROM ddHistorical WHERE ID = '5')
)
)
我想在我的数据库中的每个 ID 上运行它,我该怎么做?
这有效(http://www.sqlfiddle.com/#!2/e8ac0/3/0)
SELECT Abs(Timestampdiff(minute, Now(), (SELECT Max( ` time ` )
FROM ddhistorical
WHERE id = a.id
GROUP BY id)))
FROM ddhistorical AS A
GROUP BY id
尝试这个:-
SELECT ABS(TIMESTAMPDIFF(MINUTE, NOW(), (SELECT MAX(`Time`) FROM ddHistorical