The table Country contains the fields Code, defined as the PRIMARY KEY, and Name, which is covered by a UNIQUE index.
Which of the following queries demonstrates the correct way to compare a tuple to a row subquery?
A.
SELECT Name
FROM City c
WHERE (c.id, c.CountryCode) = (SELECT
CONCAT(Capital, Code)
FROM Country
WHERE Name = ‘United States’)
B.
SELECT Name
FROM City c
WHERE (c.id, c.CountryCode) = (SELECT Capital
FROM Country,
SELECT Code
FROM Country)
C.
SELECT Name
FROM City c
WHERE (c.id, c.CountryCode) = (SELECT Capital, Code
FROM Country)
D.
SELECT Name
FROM City
WHERE (c.id, c.CountryCode) = (SELECT Capital, Code
FROM Country
WHERE Name = ‘United States’)
Explanation:
tuple = list of ordered elements, eg list (c.id, c.CountryCode). A only returns 1 value, B is incorrect syntax, C multiple rows (no WHERE).
i think the answer is C.
A and B definitely wrong answer.
D, where the aliasing “c” for City?
C is wrong as the subquery returns more than one row..
sundul gan