Delete where TimeStamp is minimum in table

258 views Asked by At

I want delete rows in my table where I have minimum Time stamp value.

DELETE FROM `table_name` WHERE `time_Stamp` =MIN(`table_name.time_Stamp`)
3

There are 3 answers

4
Mukesh Kalgude On
DELETE FROM table_name WHERE time_Stamp =(select MIN(a.time_Stamp) from table_name a)
0
Strawberry On

E.g.:

DELETE x 
  FROM my_table x 
  JOIN 
     ( SELECT MIN(a) min_a FROM my_table ) y 
    ON y.min_a = x.a;
0
Rohitesh On

First you do a select statement like

select * FROM table_name WHERE time_Stamp =(select MIN(table_name.time_Stamp) from table_name)

and check whether you are getting all the correct records then you can use

DELETE FROM table_name WHERE time_Stamp =(select MIN(table_name.time_Stamp) from table_name)