I know how to update where it is an either/or situation. However, if I need to add more conditions to a statement I am not sure how to proceed.
The desired task is updating 1 to 10, 2 to 20, 3 to 30, 5 to 50, and 0 to 00. Would it be something like such:
update table
set own = (case
when own in '1' then '10,
case
when own in'2' then '20'.....else '00'
end);
Or would it be best to break it down to five separate update statements where 1, 2,3,5,and 0 are dealt with separately?
Desired Result
own own
1 10
2 20
3 30
5 50
0 00
You only need a single case statement. I used = versus in since you aren't supplying multiple values.
update table
set own=case
when own = '1' then '10'
when own = '2' then '20'
when own = '3' then '30'
....
else '00'
End
If your problem is only to add an '0'
try it:
update table set own = RTRIM(LTRIM(own)) + '0';
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