Deleting Records

后端 未结 3 1805
清酒与你
清酒与你 2021-01-25 13:13

I have a table [user_logs] with the following fields [username], [datetimelog]

Sample Data

==============
user1   2011-06-28 08:49:01
user2   2011-06-28          


        
3条回答
  •  醉梦人生
    2021-01-25 13:24

    DELETE FROM table a WHERE time != (SELECT MAX(time) FROM table b WHERE b.user=a.user);
    

    Here delete a row, if its not the maximum time in group with the same user_id

提交回复
热议问题