?
Solved

Update table with two where clauses

Posted on 2007-03-21
4
Medium Priority
?
204 Views
Last Modified: 2013-11-07
I want to update table using two where clauses.
Update table set sex = 'M' where sex = 'F' and sex = 'F' where sex = 'M'
It gives error "syntax error near where clause"

I want to update sex value in one update statement.
0
Comment
Question by:dotnet0824
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 800 total points
ID: 18762471
this will work better:
Update table set sex =case when sex ='F' then 'M' when sex = 'M' then 'F' end
where sex in ( 'F' ,  'M' )
0
 
LVL 17

Expert Comment

by:HuyBD
ID: 18762508
Update table set sex =case when sex ='F' then 'M' when sex = 'M' then 'F' end from table
HuyBD;
0
 
LVL 17

Assisted Solution

by:HuyBD
HuyBD earned 200 total points
ID: 18762565
sorry, I have a missing

Update table set sex =case when sex ='F' then 'M' when sex = 'M' then 'F' else sex end

HuyBD;
0
 

Author Comment

by:dotnet0824
ID: 18763092
Thanks a lot for the immediate replies.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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

752 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