Solution


Approach: Using UPDATE and CASE...WHEN [Accepted]

Algorithm

To dynamically set a value to a column, we can use UPDATE statement together when CASE...WHEN... flow control statement.

MySQL

UPDATE salary
SET
    sex = CASE sex
        WHEN 'm' THEN 'f'
        ELSE 'm'
    END;