Get the latest date from grouped MySQL data

前端 未结 7 908
一生所求
一生所求 2020-11-27 04:29

I have the following data in my database:

|NO | model | date     | 
+---+-------+----------+
|1  | bee   |2011-12-01|
|2  | bee   |2011-12-05|
|3  | bee   |2         


        
7条回答
  •  广开言路
    2020-11-27 05:03

    This should work:

    SELECT model, date FROM doc GROUP BY model ORDER BY date DESC
    

    It just sort the dates from last to first and by grouping it only grabs the first one.

提交回复
热议问题