具体两种实现方法:
1.先排序,再分组。
//受mysql版本影响,如果查询失败,请在子查询后加上limit 限制。
SELECT * FROM (SELECT * FROM f_suspend_accounts ORDER BY id desc) su WHERE su.account_id = 184995017038268
2.使用max函数。
SELECT * FROM tb_dept td
JOIN (SELECT max(id) id FROM tb_dept GROUP BY parent_id) md
on td.id = md.id;