best advice ever: in order to allow an index on the column to be used, and therefore to make your query perform well, it is important never to apply a function to a column
so your DATEDIFF approach is dead right out of the starting gate
a wise man once said that it is far better to get the correct answer after a while than a wrong answer immediately...
and to be sure, DATEDIFF can give you the right answer, but it's not efficient
if you're trying to find "more than 3 days old" you should do it this way --
Code:
WHERE `timestamp` < CURRENT_DATE - INTERVAL 3 DAY
note that you shouldn't use a reserverd word like TIMESTAMP for the name of a column
Bookmarks