PDA

View Full Version : Deleting records older than 5 minutes?


ERuiz
04-08-2007, 06:02 PM
Hello all,

I hope someone here can help me out with this. How can I write a query, which will look at a table and determine which records are older than 5 minutes and delete those records?

The table name is: liveacars
The field name which contains the timestamp is: last_update

I guess the query would be something like this:

DELETE FROM liveacars WHERE last_update...

Now, what comes after WHERE last_update, that's where I need your help.

Thanks for any help!

Logikos
04-09-2007, 05:06 AM
$fiveminsago = time() - 300;
mysql_query("DELETE FROM liveacars WHERE last_update >= $fiveminsago");
Something like that would work, in a php file.