198k views
2 votes
Which of the following SQL statements will display the title of all books that have had multiple copies requested in a single order?

a. SELECT title
FROM books NATURAL JOIN orderitems
WHERE qty > 1;
b. SELECT title
FROM books JOIN orderitems
WHERE qty > 1;
c. SELECT title
FROM books JOIN orderitems ON (isbn) JOIN orders ON (order#)
WHERE qty>1;
d. SELECT title
FROM books JOIN orderitems USING(isbn);

1 Answer

1 vote

Final answer:

The correct SQL statement to display the title of all books that have had multiple copies requested in a single order is option c.

Step-by-step explanation:

The accurate SQL query for retrieving the titles of books with multiple copies requested in a single order is option c:

```sql

SELECT title FROM books

JOIN orderitems ON books.isbn = orderitems.isbn

JOIN orders ON orderitems.order# = orders.order#

WHERE orderitems.qty > 1;

```

This query involves a three-way join among the tables books, orderitems, and orders. The JOIN keyword establishes the connections between these tables through the shared fields isbn and order#. The WHERE clause further refines the results by specifying that only records with a quantity (qty) greater than 1 in the orderitems table should be included. As a result, the query effectively identifies and retrieves the titles of books that have experienced multiple copy requests within a single order.

User JakobFerdinand
by
8.2k points