Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Update table with two where clauses

Posted on 2007-03-21
4
Medium Priority
?
206 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 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