我有以下查询在TSQL中正常工作
SELECT
shoppingcart_1.price, shoppingcart_1.stid, course.isbn,
book.BookTitle, course.Course_ID, schedule.stid AS Expr1
FROM
book
INNER JOIN
shoppingcart AS shoppingcart_1
INNER JOIN
schedule ON shoppingcart_1.cid = schedule.course_ID
INNER JOIN
course ON schedule.course_ID = course.Course_ID
ON book.isbn = course.isbn
WHERE
(shoppingcart_1.stid = '20070004')
但是当我在Mysql中运行它时,它会在行上显示错误
INNER JOIN course ON schedule.course_ID = course.Course_ID ON book.isbn = course.isbn
错误文字
1064 - 您的SQL语法出错;检查与MySQL服务器版本对应的手册,以获得正确的语法 靠近'ON book.isbn = course.isbn WHERE(shoppingcart_1.stid = '20070004')第6行限制0'
我是第一次在mysql中编写查询,请帮忙
答案 0 :(得分:1)
好像你的联盟有点混乱。我试着清理它。看看这是否适合你
SELECT shoppingcart_1.price, shoppingcart_1.stid, course.isbn, book.BookTitle, course.Course_ID, schedule.stid AS Expr1
FROM book
INNER JOIN course ON book.isbn = course.isbn
INNER JOIN schedule ON course.Course_ID = schedule.course_ID
INNER JOIN shoppingcart AS shoppingcart_1 ON schedule.course_ID = shoppingcart_1.cid
WHERE shoppingcart_1.stid = '20070004'
请注意我如何将书籍加入课程,然后安排课程,然后安排到购物车。然后使用WHERE子句指定其他条件。