Reputation: 1257
hello i am working on a database where i want to delete data which is 24hrs old ...
and i am using now() to insert data ..... here is my insert code
INSERT INTO counter_ads (page,ip,time) VALUES ( '$page', '$ref', NOW())
can any one help i want if time column is old than 24hrs it should get delete ... with mysql query. i want something like
DELETE FROM counter_ads WHERE NOW()-24 > time
i know this will not work but something like this
thx
Upvotes: 2
Views: 4463
Reputation: 125865
DELETE FROM counter_ads WHERE time < NOW() - INTERVAL 24 HOUR
You could also consider automating such a process using MySQL's event scheduler, if so desired.
Upvotes: 11