我似乎无法弄清楚我需要做什么。我有3个表,其中包含所有信息。我已经确定了步骤,但我不确定现在要做什么,我需要显示特定作者列出的所有书籍。
我需要使用3个表
到目前为止,这是代码,我知道我应该使用作者姓名,但我无法理解。
SELECT BOOK_CODE
FROM WROTE
WHERE AUTHOR_NUM = 20
LEFT JOIN AUTHOR
ON WROTE.AUTHOR_NUM = AUTHOR.AUTHOR_NUM;
答案 0 :(得分:1)
你需要书的清单,所以从书表开始然后加入写作获取特定作者然后加入作者获取作者数据
SELECT BOOK_CODE
FROM BOOK
INNER JOIN WROTE
ON WROTE.BOOK_CODE = BOOK.BOOK_CODE
AND WROTE.AUTHOR_NUM = 20
INNER JOIN AUTHOR
ON AUTHOR.AUTHOR_NUM = WROTE.AUTHOR_NUM
答案 1 :(得分:0)
SELECT Book.book_code
FROM Book
LEFT JOIN WROTE ON WROTE.book_code = Book.book_code
LEFT JOIN AUTHOR ON AUTHOR.author_code = WROTE.author_number
WHERE AUTHOR.author_code IN (123,456)