Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2006
    Posts
    12

    Question Unanswered: 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!

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    update daTable
       set daEnum = case when daEnum='0' then '1' else '0' end
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •