php mysql Group By to get latest record, not first record

前端 未结 5 683
醉话见心
醉话见心 2020-12-05 15:04

The Table:

(`post_id`, `forum_id`, `topic_id`, `post_time`) 
(79, 8, 4, \'2012-11-19 06:58:08\');
(80, 3, 3, \'2012-11-19 06:58:42\'),
(81, 9, 9, \'2012-11-1         


        
5条回答
  •  情歌与酒
    2020-12-05 15:50

    It's not very beautiful , but it works:

    SELECT * FROM (SELECT  post_id, forum_id, topic_id FROM posts
    ORDER BY post_time DESC) as temp
    GROUP BY topic_id
    

提交回复
热议问题