Reputation: 323
I have a table named jemaah :
ID name age gender
1 a 2 p
2 b 3 l
3 c 1 l
4 d 5 p
My question is how to update the value in gender column. For example i want to change the value p into f and l into m. All to together there are thousand rows.
Upvotes: 0
Views: 1324
Reputation: 225
2 updates need to be done
UPDATE tablename SET gender = "f" WHERE gender = "p"
UPDATE tablename SET gender = "m" WHERE gender = "l"
Upvotes: 0
Reputation: 12294
UPDATE jemaah SET gender = CASE gender WHEN 'p' THEN 'f' WHEN 'l' THEN 'm' END
Upvotes: 1
Reputation: 13354
UPDATE jemaah SET gender = 'f' WHERE gender = 'p';
UPDATE jemaah SET gender = 'm' WHERE gender = 'l';
Upvotes: 4