I have mistakenly inserted wrong data in table rows, now I want to swap the data. Male in place of Female and vice-versa.
Following is the correct data I am expecting -
Simple update works:
UPDATE myTable
SET
col1 = CASE WHEN col1 = 'male' THEN 'female' ELSE 'male' END,
col2 = CASE WHEN col2 = 'female' THEN 'male' ELSE 'female' END
Result: row values will be swap.
I hope, It will work for you.
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