?
Solved

How to replace the value using update statement?

Posted on 2010-08-12
3
Medium Priority
?
471 Views
Last Modified: 2012-05-10
I have table having 2 columns name and sex like this.
Name    sex
A            M
B            F
C            M
D            F

From the above table I have to change all M values to F and F values to M using a single update statement.
0
Comment
Question by:senthilkumarsb
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 750 total points
ID: 33427092
update yourtable  set sex = case when sex = 'M' then 'F' else 'M' endwhere sex in ('M', 'F')
0
 
LVL 31

Assisted Solution

by:James Murrell
James Murrell earned 750 total points
ID: 33427118
Something like should help
update table
set sex = case when sex = 'M' then 'F' else 'M' end
where sex in ('M', 'F')

James
0
 
LVL 4

Author Closing Comment

by:senthilkumarsb
ID: 33427334
Both are correct solutions
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question