How to SELECT by MAX(date)?

前端 未结 12 1597
独厮守ぢ
独厮守ぢ 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:28

    This should do it:

    SELECT report_id, computer_id, date_entered
    FROM reports AS a
    WHERE date_entered = (
        SELECT MAX(date_entered)
        FROM reports AS b
        WHERE a.report_id = b.report_id
          AND a.computer_id = b.computer_id
    )
    

提交回复
热议问题