Question: I want to delete every row where the time difference is 5 minutes. I'm using time() as an int.

```
mysql_query("DELETE FROM users WHERE time()-time > 300");

```

the query is the problem...

Answer: 
[**`time()`**](http://www.php.net/time) is a PHP function -- and has absolutely no meaning in SQL.

You should either :

* use one of MySQL's [datetime functions](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html)
	+ To get an UNIX Timestamp, I suppose `unix_timestamp(now())` might do the trick.
* or get `time()` out of the SQL query, so it's evaluated by PHP.

For example, using the second idea, I suppose you could do something like this :

```
mysql_query("DELETE FROM users WHERE " . time() . "-time > 300");

```
mysql\_query("DELETE FROM users WHERE time < '".(time()-300)."' ");  

and this query will be cached by mysql