Reputation: 642
I have a query where I want to delete all the entries which belongs to a date. I am missing how to pass a LIKE argument from the sub-query. The idea is to match a date from the last entry and delete all the matched entries.
DELETE FROM logentries WHERE datetime(timestamp) LIKE----(SELECT date(timestamp) FROM logentries ORDER BY datetime(timestamp) ASC LIMIT 1);
How to have the above 2 queries in a single query?
Upvotes: 0
Views: 100
Reputation: 157
You must convert your dates to string and it will do the trick.
Upvotes: 0
Reputation: 11161
Don't use LIKE
(there's no pattern matching here), use =
:
DELETE FROM logentries WHERE DATE(timestamp) = (SELECT DATE(timestamp) FROM logentries ORDER BY timestamp DESC LIMIT 1);
Upvotes: 1