-1

我有以下在 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 服务器版本相对应的手册,以在第 6 行的 'ON book.isbn = course.isbn WHERE (shoppingcart_1.stid = '20070004') LIMIT 0' 附近使用正确的语法

我第一次在mysql中写查询,请帮忙

4

1 回答 1

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 子句指定其他条件。

于 2012-12-17T17:45:09.973 回答