📜  mysql 获取最大值和 id - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:33.749000             🧑  作者: Mango

代码示例1
SELECT a.id, a.rev, a.contents
FROM YourTable a
INNER JOIN (
    SELECT id, MAX(rev) rev
    FROM YourTable
    GROUP BY id
) b ON a.id = b.id AND a.rev = b.rev