The current data in my table is:
a b --------- -1 5 -11 2 -5 32
My request is to convert every data of column a into negative value.
But how to update the positive values into the negative selecting the entire column?
Try this:
Update table set a= 0-a where a >0
UPDATE mytable SET a = a * -1;
This multiplies all values in 'a' by -1. Now, if the value is already negative, it will become positive. You you want to make sure they are always negative, do this:
UPDATE mytable SET a = a * -1 WHERE a > 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