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

前端 未结 5 680
醉话见心
醉话见心 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条回答
  •  萌比男神i
    2020-12-05 15:39

    This will also work fine for you.

    SELECT *
    FROM (
      SELECT post_id, forum_id, topic_id FROM posts
      ORDER BY post_time DESC
      LIMIT 5
    ) customeTable
    GROUP BY topic_id
    

提交回复
热议问题