Problem Description –
Write an SQL query to swap all
'm' values (i.e., change all
'f' values to
'm' and vice versa) with a single update statement and no intermediate temp table(s).
Note that you must write a single update statement, DO NOT write any select statement for this problem.
The query result format is in the following example:
Difficulty Level – Easy
UPDATE Salary SET sex = if(sex = 'm','f','m')
Here, we are asked to not write more than one update statement and also we can not use any select statement. This can be done using simply the If statement. If the sex is ‘m’ then the value will be ‘f’ else it will be ‘m’.