此查询之前有效,但也许我以某种方式更改了它..
select * from completed_games where date BETWEEN 2015-02-22 00:00:00 AND 2015-02-28 00:00:00
为什么这个查询不起作用,我该怎么写呢?
错误:
ER_PARSE_ERROR: 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 '00:00:00 AND 2015-02-28 00:00:00' at line 1
答案 0 :(得分:2)
您的日期无效。您需要将它们括在引号之间。
select *
from completed_games
where date BETWEEN '2015-02-22 00:00:00' AND '2015-02-28 00:00:00'
答案 1 :(得分:1)
您需要在日期字符串周围加上引号:
select *
from completed_games
where date BETWEEN '2015-02-22 00:00:00'
AND '2015-02-28 00:00:00'
答案 2 :(得分:1)
如果您不需要检查时间,您甚至可以执行以下操作:
SELECT *
FROM completed_games
WHERE `date` BETWEEN '2015-02-22' AND '2015-02-28'
提示:尝试在关键字或特殊字符周围使用反引号(`)。