How to group by DESC order

后端 未结 7 1975
终归单人心
终归单人心 2020-12-03 06:30

I have the following table called questions:

ID | asker 
1  | Bob
2  | Bob
3  | Marley

I want to select each asker only once and if there are

7条回答
  •  星月不相逢
    2020-12-03 07:23

    To get every column:

    SELECT * FROM questions
    WHERE id IN 
    (SELECT max(id) as id, asker
    FROM questions 
    GROUP by asker 
    ORDER by id DESC)
    

    Improved version of the answer of @bluefeet.

提交回复
热议问题