Which SQL statement would you execute to accomplish the task?

View the Exhibit and examine the descriptions of the DEPT and LOCATIONS tables. You want to update the CITY column of the DEPT table for all the rows with the corresponding value in the CITY column of the LOCATIONS table for each department. Which SQL statement would you execute to accomplish the task?

View the Exhibit and examine the descriptions of the DEPT and LOCATIONS tables.

You want to update the CITY column of the DEPT table for all the rows with the corresponding value in the CITY column of the LOCATIONS table for each department.

Which SQL statement would you execute to accomplish the task?

A.
UPDATE dept d
SET city = ANY (SELECT city
FROM locations l);

B.
UPDATE dept d
SET city = (SELECT city
FROM locations l)
WHERE d.location_id = l.location_id;

C.
UPDATE dept d
SET city = (SELECT city
FROM locations l
WHERE d.location_id = l.location_id);

D.
UPDATE dept d
SET city = ALL (SELECT city
FROM locations l
WHERE d.location_id = l.location_id);



Leave a Reply 3

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


user

user

B: (SELECT city FROM locations l) WHERE d.location_id = l.location_id <= (does not wrap the WHERE clause)

C: (SELECT city FROM locations l WHERE d.location_id = l.location_id) <= (wrap all)

Ramu

Ramu

What if the sub query returns more than one city? How ” C ” would be correct?

dames

dames

Only C executes successfully. l.location_id is assumed to be unique.