我使用以下SQL查询,但我一直收到错误
您的SQL语法有错误;检查与MySQL服务器版本对应的手册,以便在''
附近使用正确的语法SELECT roomID
FROM rooms
WHERE
roomID NOT IN (
SELECT t1.roomID
FROM
rooms t1
INNER JOIN reservations t2 ON t1.roomID = t2.roomID
INNER JOIN reservationdetails t3 ON t2.resDeID = t3.resDeID
WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure)
)
我不是一个非常优秀的SQL程序员......在阅读了很多SQL之后做了所有这些......
如果有人能在这里弄清楚什么是错误的话,那将是一个很大的帮助..提前感谢..
答案 0 :(得分:2)
看起来,至少你缺少)
答案 1 :(得分:1)
您错过了结束)
更改
WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure)
到
WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure))
答案 2 :(得分:0)
你的问题在这里
WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure)
尝试这样做
WHERE t3.arrival >= '2013-01-13' OR t3.departure <= '2013-02-03'
答案 3 :(得分:0)
你应该总是关闭所有打开的括号,好像你错过了一个。
SELECT roomID
FROM rooms
WHERE
roomID NOT IN (
SELECT t1.roomID
FROM
rooms t1
INNER JOIN reservations t2 ON t1.roomID = t2.roomID
INNER JOIN reservationdetails t3 ON t2.resDeID = t3.resDeID
**WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure)**
)
您可以删除not之间的括号
WHERE t3.arrival >= '2013-01-13' OR t3.departure <= '2013-02-03'
或再添加一个括号..
WHERE NOT ('2013-01-13' < t3.arrival OR ('2013-02-03' > t3.departure))