group by 获取最新的数据

SELECT
*
FROM
xxx AS t
WHERE
1 = 1
AND t.id IN (
select id FROM (
SELECT
MAX( t.id ) id
FROM
xxx AS t
WHERE
1 = 1
GROUP BY
t.id_number,
t.`class`
ORDER BY
t.id
LIMIT 0,
10 ) a
)
ORDER BY
t.id
LIMIT 0,
10

posted @ 2023-06-02 12:32  全琪俊  阅读(54)  评论(0编辑  收藏  举报