It's better to compare
`date`< DATE(NOW() - INTERVAL 30 DAY)
rather than
DATEDIFF(date,NOW()) = -30
In the first case, the date calculation is done only once, at the beginning of the query, and the database can use any indexes on the date column.
The second query must calculate the DATEDIFF
on every row, and the database can't use any indexes. The second query forces a full table scan.
Also, I strongly suggest that you not call your column date
. Yes, I know you can quote the name with backticks, but that's just messy and when you forget then your syntax errors will be hard to forget. Come up with a more descriptive name for the column. What kind of date is it? What does the date represent?