Wednesday, December 25, 2013

updating multiple column values in single query

update email_table
set EmailId = CASE id

     WHEN 1 THEN 'abc@gmail.com, xyz@gmail.com'
     WHEN 4 THEN '123@gmail.com'
     WHEN 5 THEN 'asdf@hotmail.com'
     WHEN 7 THEN 'zxcv@gmail.com'

END
WHERE id IN(1,4,5,7)

No comments:

Post a Comment