You want to use a CASE
expression of some type.
In SQL Server the code would look like this:
UPDATE TableName
SET gender = CASE WHEN gender = 'M' THEN 'W'
WHEN gender = 'W' THEN 'M'
ELSE gender END
Edit: As stated in the comments (and some of the other answers) the ELSE isn't necessary if you put a WHERE clause on the statement.
UPDATE TableName
SET gender = CASE WHEN gender = 'M' THEN 'W'
WHEN gender = 'W' THEN 'M' END
WHERE gender IN ('M','W')
This avoids unnecessary updates. The important thing in either case is to remember that there are options other than M & W (NULL for example) and you don't want to put in mistaken information. For example:
UPDATE TableName
SET gender = CASE WHEN gender = 'M' THEN 'W'
ELSE 'M' END
This would replace any NULLs (or other possible genders) as 'M' which would be incorrect.
A couple of other options would be
/*Simple form of CASE rather than Searched form*/
UPDATE TableName
SET gender = CASE gender
WHEN 'M' THEN 'W'
WHEN 'W' THEN 'M'
END
WHERE gender IN ( 'M', 'W' );
And a more concise
/*For SQL Server 2012+*/
UPDATE TableName
SET gender = IIF(gender = 'M', 'W', 'M')
WHERE gender IN ( 'M', 'W' );