5.3k views
5 votes
Which SQL statement retrieves the title, cost, contact, and phone information from the 'publisher' and 'books' tables using the 'pubid' as the common field?

A. SELECT title, pubdate, name FROM publisher JOIN books USING (pubid);
B. SELECT title FROM books NATURAL JOIN orderitems WHERE qty > 1;
C. SELECT UNIQUE name FROM books NATURAL JOIN publisher WHERE category = 'COMPUTER';
D. SELECT title, cost, contact, phone FROM publisher JOIN books USING (pubid);

1 Answer

2 votes

Final answer:

The correct SQL statement is Option D, which uses JOIN to retrieve title, cost, contact, and phone details from 'publisher' and 'books' tables based on the common field 'pubid'.

Step-by-step explanation:

The SQL statement that retrieves the title, cost, contact, and phone information from the 'publisher' and 'books' tables using the 'pubid' as the common field is: D. SELECT title, cost, contact, phone FROM publisher JOIN books USING (pubid);

This statement performs an SQL JOIN operation, which allows you to combine rows from two or more tables based on a related column between them, in this case, the 'pubid'. The USING clause specifies the common column that is used to join the tables. As a result, the output will contain a combination of records from both 'publisher' and 'books' where the 'pubid' matches, showing details of the book's title, its cost, and the publisher's contact and phone information.

User Jbtd
by
7.1k points