MySQL Order before Group by

后端 未结 10 1158
渐次进展
渐次进展 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条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-27 05:07

    What do you think about this?? Seems to work for me

    SELECT wp_posts.post_author, MAX(wp_posts.post_date), wp_posts.status, wp_posts.post_type
    FROM wp_posts
        WHERE wp_posts.post_status='publish'
        AND wp_posts.post_type='post'
        GROUP BY wp_posts.post_author
    

    It brings me all the Authors with the most updated post_date ... Do you identify a problem there?? I don't

提交回复
热议问题