Solved

Update table with two where clauses

Posted on 2007-03-21
4
190 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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…

809 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