Which query produces the expected output?

Given the data:

Expected output:

Which query produces the expected output?

Given the data:

Expected output:

Which query produces the expected output?

A.
SELECT colors2.name, colors1.name
FROM colors2
OPTIONAL JOIN colors1
ON colors2.name, colors1.name

B.
SELECT colors2.name, colors1.name
FROM colors2
NATURAL JOIN colors1
ON colors2.name=colors1.name

C.
SELECT colors2.name, colors1.name
FROM colors2
STRAIGHT JOIN colors1
ON colors2.name, =colors1.name

D.
SELECT colors2.name,colors1.name
FROM colors2
LEFT JOIN colors1
ON colors2.name=colors1.name

E.
SELECT colors2.name,colors1.name
FROM colors2
RIGHT JOIN colors1
ON colors2.name=colors1.name



Leave a Reply 6

Your email address will not be published. Required fields are marked *


Auriemma Francesco

Auriemma Francesco

correct is E

Jay

Jay

E

From MySQL 5.0 Certification Study Guide by Dubois, Hinz, and Pedersen:
“The right table is the reference table, so a RIGHT JOIN produces a result for each row in the right table, whether or not it has any match in the left table.”

hence the NULLs in the left table.