Ch. 9 Joining Tables Flashcards
Which of the following SQL statements will list the name of each customer stored in the CUSTOMERS table, and, if the customer has placed an order that is contained in the ORDERS table, the order# of any order each customer has placed?
SELECT lastname, firstname, order#
FROM customers NATURAL JOIN orders
WHERE orders.customer# IS NOT NULL;
SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# (+) = customers.customer#;
SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# = customers.customer# (+);
SELECT lastname, firstname, order#
FROM customers NATURAL JOIN orders
WHERE orders.customer# IS NULL;
SELECT lastname, firstname, order#
FROM customers, orders
WHERE orders.customer# (+) = customers.customer#;
Which of the following SQL statements will display the names of all customers who have purchased a copy of E-BUSINESS THE EASY WAY?
SELECT lastname, firstname
FROM customers NATURAL JOIN books
WHERE title LIKE ‘%BUSI%’;
SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE title LIKE ‘%BUSI%’;
SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE c.customer# = o.customer# AND o.order# = oi.order# AND
oi.isbn = b.isbn AND title LIKE ‘%BUSI%’;
none of the above
SELECT lastname, firstname
FROM customers c, books b, orders o, orderitems oi
WHERE c.customer# = o.customer# AND o.order# = oi.order# AND
oi.isbn = b.isbn AND title LIKE ‘%BUSI%’;
Which of the following types of joins is created by matching equivalent values in each table?
Cartesian join
equality join
non-equality join
outer join
equality join
Which of the following keywords is used to create a Cartesian join?
OUTER JOIN
CROSS JOIN
NATURAL JOIN
JOIN…USING
CROSS JOIN
Which of the following queries will display data from both the ORDERS and CUSTOMERS tables?
SELECT * FROM orders, customers;
SELECT lastname, firstname, order#
FROM orders NATURAL JOIN customers;
SELECT lastname, firstname, order#
FROM orders, customers
WHERE orders.customer# = customers.customer#;
all of the above
all of the above
A table alias can consist of a maximum of ____ characters.
12
225
255
30
30
Which of the following types of joins refers to joining a table to itself?
Cartesian join
equality join
self-join
outer join
self-join
Which of the following SQL statements will return the names of all customers who placed an order on April 12, 2003?
SELECT lastname, firstname
FROM customers
WHERE orderdate = ‘12-APR-03’;
SELECT lastname, firstname
FROM customers NATURAL JOIN orders
WHERE orderdate = ‘12-APR-03’;
SELECT lastname, firstname
FROM customers JOIN orders ON (customer#)
WHERE orderdate = ‘12-APR-03’;
both a and b
SELECT lastname, firstname
FROM customers NATURAL JOIN orders
WHERE orderdate = ‘12-APR-03’;
Which of the following types of joins refers to results consisting of each row from the first table being replicated from every row in the second table?
outer join
non-equality join
self-join
Cartesian join
Cartesian join
In a Cartesian join, linking a table that contains 10 rows to a table that contains 9 rows will result in ____ rows being displayed in the output.
19
18
90
89
90
Which of the following set operators will display the results of the combined SQL statements without suppressing duplicate rows?
UNION
UNION ALL
INTERSECT
MINUS
UNION ALL
Which of the following SQL statements will display the gift that should be sent to any customer who orders the book titled THE WOK WAY TO COOK?
SELECT title FROM promotion
WHERE retail BETWEEN minretail AND maxretail;
SELECT title FROM promotion NATURAL JOIN books
WHERE retail BETWEEN minretail AND maxretail;
SELECT title FROM promotion JOIN books
USING retail BETWEEN minretail AND maxretail;
none of the above
none of the above
The JOIN keyword is included in which of the following clauses?
SELECT
FROM
WHERE
ORDER BY
FROM
Which of the following SQL statements will display the gift that should be sent to any customer who orders the book titled SHORTEST POEMS?
SELECT gift FROM promotion
WHERE gift = minretail;
SELECT gift FROM promotion, books
WHERE retail >= minretail AND title = ‘SHORTEST POEMS’;
SELECT gift FROM promotion, books
WHERE retail BETWEEN minretail AND maxretail
AND title = ‘SHORTEST POEMS’;
none of the above
SELECT gift FROM promotion, books
WHERE retail BETWEEN minretail AND maxretail
AND title = ‘SHORTEST POEMS’;
Which of the following SQL statements will display the title of all books that have had multiple copies requested in a single order?
SELECT title
FROM books NATURAL JOIN orderitems
WHERE qty > 1;
SELECT title
FROM books JOIN orderitems
WHERE qty > 1;
SELECT title
FROM books JOIN orderitems ON (isbn) JOIN orders ON (order#)
WHERE qty>1;
SELECT title
FROM books JOIN orderitems USING(isbn);
SELECT title
FROM books NATURAL JOIN orderitems
WHERE qty > 1;