我收到以下 SQL PDO 语句的语法错误,你能告诉我错误在哪里吗?谢谢!
SELECT *
FROM events
WHERE
(start_date BETWEEN '2013-01-14' AND '2013-01-20')
OR (start_date NOT < '2013-01-14' and end_date > '2013-01-20')
您在第一部分的日期之后缺少一个 '。
SELECT * FROM events WHERE (start_date BETWEEN '2013-01-14' AND '2013-01-20') OR (start_date NOT < '2013-01-14' and end_date > '2013-01-20')
你不能放在NOT
表达式的中间,它在表达式之前:
NOT start_date < '2013-01-14'
或者使用运算符的补码<
,即>=
:
start_date >= '2013-01-14'
(使用的例外NOT
是IS NULL
运算符,其中NOT x IS NULL
和都x IS NOT NULL
起作用。)
您在 2013-01-20 之后错过了一个勾号
SELECT * FROM events
WHERE
(start_date BETWEEN '2013-01-14' AND '2013-01-20')
OR (start_date >= '2013-01-14' and end_date > '2013-01-20')