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

Join Shalyam Newsletter

Get exclusive insights with every issue: education, research and innovation news.

One email a week. Unsubscribe any time.