I have a table named ticket. I am trying to query between two dates, however; I keep getting a syntax error. Any help would appreciated as to what this syntax error may be.
SELECT date
FROM ticket
WHERE date BETWEEN YEAR(ticket.date)=2011 AND MONTH(ticket.date)=11 AND DAY(ticket.date)=06
AND YEAR(ticket.date)=2011 AND MONTH(ticket.date)=11 AND DAY(ticket.date)=12
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 ‘=2011 AND MONTH(ticket.date)=11 AND DAY(ticket.date)=06 AND YEAR(ticket.date)=20’ at line 1
doesn’t make any sense. The syntax is
So presumably something like
Or as you have a time component you should avoid use of
BETWEENat all and just use