MySQL结构
|ID | ID |招聘人员|创建日期||
|1 | 222   | 2018-08-15 |
|2 | 222   | 2018-08-16 |
|3 | 222   | 2018-08-17 |
MySQL选择

SELECT * FROM table WHERE id_recruiter=222 GROUP BY id_recruiter ORDER BY ID DESC

结果:| 1 | 222 | 2018-08-15|
我想得到最后一张唱片:3 | 222 | 2018-08-17|
请给我解决办法。非常感谢!

最佳答案

尝试以下查询:使用最大聚合

SELECT max(id) as id, id_recruiter,max(date_created) as date_created FROM table
WHERE id_recruiter=222
GROUP BY id_recruiter

关于mysql - GROUP BY id_recruiter ORDER BY ID DESC不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51888183/

10-10 14:29