Which UPDATE statement is valid?

Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES
___________
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
NEW_EMPLOYEES
________________
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which UPDATE statement is valid?

Examine the structure of the EMPLOYEES and NEW_EMPLOYEES tables:
EMPLOYEES
___________
EMPLOYEE_ID NUMBER Primary Key
FIRST_NAME VARCHAR2(25)
LAST_NAME VARCHAR2(25)
HIRE_DATE DATE
NEW_EMPLOYEES
________________
EMPLOYEE_ID NUMBER Primary Key
NAME VARCHAR2(60)
Which UPDATE statement is valid?

A.
UPDATE new_employees SET name = (SELECT last_name||
first_name
FROM employees
WHERE employee_id
=180)
WHERE employee_id =180;

B.
UPDATE new_employees SET name = (SELECT last_name ||
first_name
FROM employees
WHERE employee_id
=180)
WHERE employee_id =(SELECT employee_id
FROM new_employees);

C.
UPDATE new_employees SET name = (SELECT last_name||
first_name
FROM employees
WHERE employee_id =
(SELECT employee_id
FROM new_employees))
WHERE employee_id
=180;

D.
UPDATE new_employees SET name = (SELECT
last_name||first_name
FROM employees )
WHERE employee_id =180;

Explanation:

Sub-query in this answer will return one row value, concatenated first and last name for the
employee with ID 180, so update will be successful. When sub-queries are linked to the parent by
equality comparisons, the parent query expects only one row of data from the sub-query.



Leave a Reply 1

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