I want to update multiple column with multiple condition. for.eg.
update student set name='john' where id=10
update student set name='doe' where id=5
How to update this in a single statement?
I want to update multiple column with multiple condition. for.eg.
update student set name='john' where id=10
update student set name='doe' where id=5
How to update this in a single statement?
Use CASE WHEN
update student
set name= CASE WHEN id = 5 THEN 'john'
WHEN id = 10 THEN 'doe'
ELSE name
END
where id in (
5, 10
)