嗨,我有以下查询的问题 .
SELECT id, user_id, cloth_id FROM `items` GROUP BY user_id ORDER BY id desc LIMIT 3
我希望 group by
的最新记录,但不知何故它显示旧的记录 .
我也经历了MySQL - Group by with Order by DESC但没有按预期工作 .
嗨,我有以下查询的问题 .
SELECT id, user_id, cloth_id FROM `items` GROUP BY user_id ORDER BY id desc LIMIT 3
我希望 group by
的最新记录,但不知何故它显示旧的记录 .
我也经历了MySQL - Group by with Order by DESC但没有按预期工作 .
1 回答
试试这个:
在
temp
中,您将获得每个用户的最新ID .在
i
中,您获得该组合的cloth_id