Which method can you use to change the cell_no value to ‘555-8888’ for John Doe?

Review the definition of the phone_list view.
CHEATE OR REPLACE
ALGORITHM=MERGE
DEFINER= ‘root’@localhost’
SQL SECURITY DEFINER
VIEW ‘phone_list’ AS
SELECT
e . id as id
‘e . first_name AS ‘first_name’
‘e . last_name AS ‘last_name’
‘coalesce ( ph1.phone_no, ‘–‘) AS ‘office_no’
‘coalesce (ph2 .phone_no, ‘–‘) AS ‘cell_no’
FROM employees e
LEFT JOIN employee_phone ph1
ON ph1.emp_id = e.id AND ph1.type = ‘office’
LEFT JOIN employee_phone ph2
ON ph2 .emp_id = e.id AND ph2 .type = ‘mobile’
The tables employees and employee_phone are InnoDB tables; all columns are used in this view.
The contents of the phone_list view are as follows:
Mysql> select * from phone_list;

1 row in set (0.00 sec)
Which method can you use to change the cell_no value to ‘555-8888’ for John Doe?

Review the definition of the phone_list view.
CHEATE OR REPLACE
ALGORITHM=MERGE
DEFINER= ‘root’@localhost’
SQL SECURITY DEFINER
VIEW ‘phone_list’ AS
SELECT
e . id as id
‘e . first_name AS ‘first_name’
‘e . last_name AS ‘last_name’
‘coalesce ( ph1.phone_no, ‘–‘) AS ‘office_no’
‘coalesce (ph2 .phone_no, ‘–‘) AS ‘cell_no’
FROM employees e
LEFT JOIN employee_phone ph1
ON ph1.emp_id = e.id AND ph1.type = ‘office’
LEFT JOIN employee_phone ph2
ON ph2 .emp_id = e.id AND ph2 .type = ‘mobile’
The tables employees and employee_phone are InnoDB tables; all columns are used in this view.
The contents of the phone_list view are as follows:
Mysql> select * from phone_list;

1 row in set (0.00 sec)
Which method can you use to change the cell_no value to ‘555-8888’ for John Doe?

A.
DELETE FROM phone_list WHERE first_name= ‘John’ and last_name= ‘Doe’;
INSERT INTO phone_list (first_name, last_name, office_no, cell_no) VALUES
(‘John’ , ‘Doe’ , ‘x1234’ , ‘555-8888);

B.
INSERT INTO employee_phone (emp_id, phone_no, type) VALUES (1, ‘555-8888’,’mobile’);

C.
UPDATE phone_list SET cell_name ‘555-8888’ WHERE first_name= ‘John’ and last_name=
‘Doe’;

D.
UPDATE employee_phone SET phone_no= ‘555-8888’ where emp_id=1;

Explanation:



Leave a Reply 7

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


kyo

kyo

Why not C

kyo

kyo

can’t use update

omid

omid

The table employee_phone already contains a row with id=1 so you have only to UPDATE the value fot phone_number. The rignt answer is D.
INSERT is WRONG!

Jdo

Jdo

B.

MariaDB [jdo]> select * from phone_list where id =1;
+——+————+———–+———+
| id | first_name | office_no | cell_no |
+——+————+———–+———+
| 1 | empl | 1234 | |
+——+————+———–+———+
1 row in set (0.00 sec)

MariaDB [jdo]> insert into employee_phone values (1,
-> ‘mobile’, 4321);
Query OK, 1 row affected (0.00 sec)

MariaDB [jdo]> select * from phone_list where id =1;
+——+————+———–+———+
| id | first_name | office_no | cell_no |
+——+————+———–+———+
| 1 | empl | 1234 | 4321 |
+——+————+———–+———+
1 row in set (0.00 sec)

MariaDB [jdo]>