Bird
0
0

Given tables Author, Book, and junction table AuthorBook with columns AuthorID and BookID, what does this query return?

medium📝 query result Q13 of 15
SQL - Table Relationships
Given tables Author, Book, and junction table AuthorBook with columns AuthorID and BookID, what does this query return?
SELECT Author.Name, Book.Title FROM Author
JOIN AuthorBook ON Author.ID = AuthorBook.AuthorID
JOIN Book ON Book.ID = AuthorBook.BookID;
AA list of authors and the titles of books they wrote
BA list of books without any author names
CA list of all authors with all books, including unrelated pairs
DAn error because of missing WHERE clause
Step-by-Step Solution
Solution:
  1. Step 1: Understand JOINs with junction table

    The query joins Author to AuthorBook by AuthorID, then AuthorBook to Book by BookID, linking authors to their books.
  2. Step 2: Result of the query

    It returns pairs of author names and book titles where the author wrote the book, no unrelated pairs included.
  3. Final Answer:

    A list of authors and the titles of books they wrote -> Option A
  4. Quick Check:

    JOINs with junction table = related pairs only [OK]
Quick Trick: JOIN junction table to get related pairs only [OK]
Common Mistakes:
MISTAKES
  • Thinking it returns all combinations of authors and books
  • Expecting an error without WHERE clause
  • Ignoring the role of junction table in filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes