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
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With