Update multiple rows & columns using a single statement
634624Jul 11 2008 — edited Jul 11 2008I have the following table with tablename - emp
first_name last_name age
--------------- --------------- ----
aaa bbb 31
56
78
ggg hhh 36
-----------------------------------------------
2nd & 3rd row contain null values (no data) in first_name & last_name column . I want to update those two rows with data using a single statement. How do I do it?
I was thinking may be something like the following:-
----------------------------------------------
UPDATE emp
SET first_name= , last_name=
CASE
WHEN age = 56 THEN 'ccc', 'ddd'
WHEN age = 78 THEN 'eee', 'fff'
ELSE first_name, last_name
END
-----------------------------------------------