I must be doing something glaringly obvious here, but I am just starting with MySQL and can't work this out!
I have a table, orders, and two DATE fields in it that are used to filter out holidays, holdstart and holdend. These are both DATE fields (not DATETIME), notnull. As such, they default to 0000-00-00.
I want to find customers who are on hold - that is customers who have a value in holdstart and holdend other than 0000-00-00.
I tried using this query:
SELECT *
FROM orders
ORDER BY holdstart
WHERE holdstart > '0000-00-00'
...but this throws back an error. Through phpMyAdmin, the error is:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE holdstart > '0000-00-00'
LIMIT 0, 30' at line 1
If I take out the WHERE statement, the query works fine. Obviously something is wrong there. I have tried different values, such as holdstart = '0000-00-00' or holdstart = holdend, but still get an error.
What am I doing wrong?