MySQL结构
| ID | id_recruiter | date_created |
| 1 | 222 | 2018-08-15 |
| 2 | 222 | 2018-08-16 |
| 3 | 222 | 2018-08-17 |
MySQL Select
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 |
请给我解决方法。非常感谢!
答案 0 :(得分:1)
尝试以下查询:使用MAX聚合
SELECT max(id) as id, id_recruiter,max(date_created) as date_created FROM table
WHERE id_recruiter=222
GROUP BY id_recruiter