Reputation: 1281
I have following query, but it gives me errors, if anyone could give me a hint, would be awesome.
SELECT tblinvoices.*,companyname FROM tblinvoices INNER JOIN tblclients
ON tblclients.id=tblinvoices.clientid
WHERE 1=1 AND date between '20111201' to '20111208'
The error message is:
Error 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 'TO '20111208''
Upvotes: 2
Views: 80
Reputation: 35138
use AND
instead of TO
in the BETWEEN
command.
SELECT tblinvoices.*,companyname FROM tblinvoices INNER JOIN tblclients
ON tblclients.id=tblinvoices.clientid
WHERE 1=1 AND date between '20111201' AND '20111208'
Upvotes: 2
Reputation: 40061
If companyname is from tblinvoices it should work, otherwise you need to check where companyname comes from. And the syntax for between is like this
date between '20111201' and '20111208'
Upvotes: 0
Reputation:
I am pretty sure is the word TO, it should be:
SELECT tblinvoices.*,companyname FROM tblinvoices INNER JOIN tblclients ON tblclients.id=tblinvoices.clientid WHERE 1=1 AND date between '20111201' AND '20111208'
Upvotes: 0