How to SELECT by MAX(date)?

前端 未结 12 1607
独厮守ぢ
独厮守ぢ 2020-12-03 02:49

This is the table structure:

CREATE TABLE `reports` (
  `report_id` int(11) NOT NULL auto_increment,
  `computer_id` int(11) NOT NULL default \'0\',
  `date_e         


        
12条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 03:47

    Are you only wanting it to show the last date_entered, or to order by starting with the last_date entered?

    SELECT report_id, computer_id, date_entered
    FROM reports
    GROUP BY computer_id
    ORDER BY date_entered DESC
    -- LIMIT 1 -- uncomment to only show the last date.
    

提交回复
热议问题