renisenbb
asked on
SQL: Want to update multiple rows in one statement
Let's say i have 3 rows:
id year
-- --------
10 1980
11 1981
12 1992
I want to update these rows so that it is :
10 1970
11 1901
12 1980
So i want to update ids 10,11,12 with the year 1970,1901,1980 RESPECTIVELY.
How would i do this in DB2?
id year
-- --------
10 1980
11 1981
12 1992
I want to update these rows so that it is :
10 1970
11 1901
12 1980
So i want to update ids 10,11,12 with the year 1970,1901,1980 RESPECTIVELY.
How would i do this in DB2?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No.
ASKER
It worked.
Update Year_Master(your table) set year=
case
when id = 10 then 1970
when id = 11 then 1901
when id = 12 then 1980
end
WHERE id in (10,11,12)