I want to delete rows from a table that has a column more than 7200 secs old.
The Query
mysql_query("delete from logged where DATE_ADD ( log, INTERVAL $this->loginDuration SECOND) < NOW()",$this->link);
where:
name of table = logged;
name of column = log;
$this->loginDuration = 7200;
The value of log in db: 2011-06-25 09:56:51.
Todays date and time [ Now() ] : 2011-07-05 11:39:02
The query is meant to delete the row with log value 2011-06-25 09:56:51 because it is older than 7200 seconds but it does not.
What am I not getting right?
You have a space between
DATE_ADDand the parenthesis:( log, ....Use
DATE_ADD( log, ...From MySQL docs, Functions and Operators :
And: