Solved

Update table with two where clauses

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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
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
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

717 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