update mysql table each row in with where condition one query

Hi I’m trying to update each row column in a mysql table with where condition

update city set (ID='1001' where ID='1') and (ID='1002' where ID='2'); 

but this seems not working Can anyone have suggestions?


Use a CASE expression:

update city 
set ID = case ID
  when '1' then '1001' 
  when '2' then '1002' 
where ID IN ('1', '2'); 

or simpler:

update city 
set ID = ID + 1000
where ID IN ('1', '2');