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?
Who is Participating?
renisenbbAuthor Commented:
Thanks, that worked. What if the second row update was not successful, will that roll back the update for the first row?
Naitik GamitSoftware DeveloperCommented:
try like,

Update Year_Master(your table) set year=
     when id = 10 then 1970
     when id = 11 then 1901
     when id = 12 then 1980
     WHERE id  in (10,11,12)
Naitik GamitSoftware DeveloperCommented:
renisenbbAuthor Commented:
It worked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.