How To Update Rows With Different Values In One Query

I am going to share how to update rows with different values in One Query. I have user data table. I have more then 100 user data. The user’s gender has changed by mistake. So I want to change Gender mail to female and female to male.

In below Example you can use to update (mail to female and female to male) data in one SQL query

Example

UPDATE `tab1`
SET `Value`=
CASE
   WHEN `Value`='male' THEN 'female'
   WHEN `Value`='female' THEN 'male'
   ELSE 'other'
END;
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments