首页 > 代码库 > mysql分组取每组大的记录

mysql分组取每组大的记录

SELECT a.* FROM chat_log a INNER JOIN (SELECT id,MAX(id) id_,to_user FROM chat_log GROUP BY to_user)b ON a.to_user=b.to_user AND a.id=b.id ORDER BY a.to_user;  

 

mysql分组取每组大的记录