Reputation: 63
I want to delete a specific date record from MYSQL table
Date insert in TIMESTAMP
i tried this query but not worked:
DELETE FROM `tracking` WHERE `track_time` = '2015-03-07'
Records in table are present in that time stap like
DELETE FROM `tracking` WHERE `track_time` = '2015-03-07'
2014-05-28 00:00:02
Let me know please
Upvotes: 2
Views: 3261
Reputation: 107237
For performance reasons, if you have a large number of rows, and you have an index on track_time
, consider the simple case of a range based filter, instead of applying functions like date()
in the where
predicate:
DELETE FROM tracking WHERE track_time >= '2015-03-07' AND track_time < '2015-03-08';
Upvotes: 1
Reputation: 614
This may by the query you're looking for:
DELETE FROM tracking WHERE date(track_time) like '2015-03-07'
Let me know if that solve your problem.
Upvotes: 0
Reputation: 172378
Try this:
DELETE FROM tracking WHERE date(track_time) = '2015-03-07'
or
DELETE FROM tracking
WHERE track_time > '2015-03-07 00:00:02' and track_time < '2015-03-08 00:00:02'
Upvotes: 1
Reputation: 44844
You need to extract the date out of timestamp using date
function as
DELETE FROM tracking WHERE date(track_time) = '2015-03-07'
Upvotes: 0