mysql分组取每组大的记录

SELECT a.* FROM chat_log a INNER JOIN (SELECT 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;  

 

转载于:https://www.cnblogs.com/007sx/p/6753844.html

你可能感兴趣的:(mysql分组取每组大的记录)