Select latest row from multiple tables
问题 I have this query with multiple tables and I got the following result. Then I want to group by t.id. I know I can simply use group by t.id but how can I select the latest row of t.id which is url tw5.jpg and created_time 10000004 SELECT p.url,t.name,t.num_photo,t.id FROM photos AS p LEFT JOIN tag_maps AS tm ON p.id = tm.photo_id LEFT JOIN tags AS t ON t.id = tm.tag_id url created_time name num_photo id assets/img/tags/tw1.jpg 1000001 my house 1 1 assets/img/tags/tw2.jpg 1000002 dog 1 2 assets