我有以下查询,但它给了我错误,如果有人能给我一个提示,那就太棒了。
SELECT tblinvoices.*,companyname FROM tblinvoices INNER JOIN tblclients
ON tblclients.id=tblinvoices.clientid
WHERE 1=1 AND date between '20111201' to '20111208'
错误消息是:
错误1064:您的SQL语法出错;检查 手册,对应右边的MySQL服务器版本 在'TO'2011118''
附近使用的语法
答案 0 :(得分:2)
在AND
命令中使用TO
代替BETWEEN
。
SELECT tblinvoices.*,companyname FROM tblinvoices INNER JOIN tblclients
ON tblclients.id=tblinvoices.clientid
WHERE 1=1 AND date between '20111201' AND '20111208'
答案 1 :(得分:0)
我很确定这个词是TO,应该是:
SELECT tblinvoices。*,companyname FROM tblinvoices INNER JOIN tblclients ON tblclients.id = tblinvoices.clientid WHERE 1 = 1 AND日期介于'20111201' AND '20111208'
答案 2 :(得分:0)
如果公司名称来自tblinvoices,它应该有效,否则您需要检查公司名称的来源。而之间的语法就像这样
date between '20111201' and '20111208'