What is wrong with this SQL?
It seems like it should work, but it doesn’t.
utc_time is a datetime field.
SELECT id
FROM `foo`
WHERE utc_time > now()
AND utc_time <= DATE_ADD(curdate(),INTERVAL 24 day);
Explain says that the Where clause is impossible.
utc_time is type datetime. Here is a sample utc_time value: 2011-06-21 00:45:00
utc_time()is a built-in function. Even without the brackets,utc_timestill returns the current UTC time.Escape the column named
utc_time. This works (I tested it):Yet another example of why it’s a bad idea to use reserved words or function names as column/table names.