Last answered:

28 Sept 2022

Posted on:

18 Nov 2021

0

How to update two records at a time?

In the video, it is teaching how to update a record by using WHERE clause. (WHERE emp_no = 999901)
If we want to update two employees in the same time, how can we write?

3 answers ( 0 marked as helpful)
Instructor
Posted on:

01 Dec 2021

0

Hi Moe!

Great to have you in the course and thanks for reaching out!
You can use the following syntax:

UPDATE table_name
SET column_name_1 = CASE column_name_2
    WHEN 'name1'
THEN 'value'     WHEN 'name2' THEN 'value2' 
    ELSE column_name_1
    END
 WHERE column_name_2 IN('name1', 'name2');



Hope this helps.
Best,
Martin

Posted on:

27 Sept 2022

0

Hi! Martin
could you pls explain the role of the else rest of the code I understood but not the else column_name_1 code?
Thanks in advance
(also it would be more beneficial if this kind of important stuff would be added as a bonus tutorial)

Instructor
Posted on:

28 Sept 2022

1

Hi Mayank!
Thanks for reaching out.

If the condition is not met, then we simply return this column. This condition is applied only for specific column names. They are included in the IN() operator.

Hope this helps.
Best,
Tsvetelin

Submit an answer