Skip to main content
Admissions guidance, study banks, and career tools — get started on Shalyam

Swap Gender Values

Write a single UPDATE statement that swaps all 'm' values with 'f' and all 'f' with 'm' in the sex column. Do not use any temporary table or SELECT.

Table schema

Salary(id INT PRIMARY KEY, name VARCHAR(50), sex CHAR(1), salary INT)

Sample data

id | name | sex | salary
1 | A | m | 2500
2 | B | f | 1500
3 | C | m | 5500
4 | D | f | 500

Discussion

No discussions yet.

Rewards · v2.1

Get Exclusive Insights with Every Issue

Join Shalyam Newsletter

Stay ahead in education, research, and innovation—straight to your inbox.