MySQL Order before Group by

后端 未结 10 1162
渐次进展
渐次进展 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 04:45

    HERE a simple answer from http://www.cafewebmaster.com/mysql-order-sort-group

    SELECT * FROM 
    (
    select * from `my_table` order by timestamp desc
    ) as my_table_tmp
    
    GROUP BY catid
    ORDER BY nid desc
    

    it worked wonders for me

提交回复
热议问题