MySQL Order before Group by

后端 未结 10 1165
渐次进展
渐次进展 2020-11-27 04:41

I need to find the latest post for each author and then group the results so I only a single latest post for each author.

SELECT wp_posts.* FROM wp_posts
            


        
10条回答
  •  萌比男神i
    2020-11-27 04:56

    Do a GROUP BY after the ORDER BY by wrapping your query with the GROUP BY like this:

    SELECT t.* FROM (SELECT * FROM table ORDER BY time DESC) t GROUP BY t.author
    

提交回复
热议问题