If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > update enum flip?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-06, 08:57
ironCode ironCode is offline
Registered User
 
Join Date: Oct 2006
Posts: 12
Question update enum flip?

I have a data field that is a simple enum('0','1') is it possible to update it and just flip the results? So for example i have a 0 and want to simply flip it to 1 but on the other hand it might be a 1 and i want to flip it to a 0 with the same query. Is this possible or would i have to use the scripting language and do a normal update?

Any help would be great!
Reply With Quote
  #2 (permalink)  
Old 10-25-06, 09:36
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
Code:
update daTable
   set daEnum = case when daEnum='0' then '1' else '0' end
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 10-25-06, 09:43
ironCode ironCode is offline
Registered User
 
Join Date: Oct 2006
Posts: 12
woot that was exactly what i was looking for. Thanks!

I was trying to do it with a sub-select and wasn't able to get it done lol
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On