How to SELECT by MAX(date)?

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

    Workaround but working solution

    Only if ID is autoincrement, you can search for the maximum id instead of the max date. So, by the ID you can find all others fields.

    select *
    from table
    where id IN ( 
                  select max(id)
                  from table
                  group by #MY_FIELD#
                  )
    

提交回复
热议问题