In this table I want to delete the oldest entry for userid 1, here the oldest entry is ghi 10/12/2011 11:20:22 i get the oldest entry by the datetime. How can I compare date time and do a delete in the same query. I want to compare the datetime entry for userid 1
delete from tbl_name where datetime is oldestentry and userid=1;
No Name DateTime UserID
1 abv 12/12/2011 11:20:22 1
2 edf 11/12/2011 11:20:22 1
3 ghi 10/12/2011 11:20:22 1
This does not work in MySQL:
but this does: