Solved

Update table with two where clauses

Posted on 2007-03-21
4
184 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
  • 2
4 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 200 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 50 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

705 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now