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?
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
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)
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