时间戳字段是DATETIME
格式类似于 的列2012-03-19 00:23:14
。如何比较两行时间戳并找到较大的时间戳?我正在使用的下面的查询不起作用。
UPDATE report 1 status = 'time is larger' WHERE EXISTS
(SELECT ip_src, layer4_sport, timestamp FROM
(SELECT ip_src, layer4_sport, timestamp from report 1) AS tmpb
WHERE report 1.layer4_sport = tmpb.layer4_sport
AND report 1.ip_src = tmpb.ip_src
AND report 1.timestamp > tmpb.timestamp
GROUP BY ip_src, layer4_sport, timestamp HAVING COUNT(*) = 2)