MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Christoph Boget Date:January 8 2009 8:18pm
Subject:UPDATE jujitsu?
View as plain text  
Consider the folowing dataset:

+----+------------+-------------+-------------+---------------+
| id    | Name     | Location    | OnOffFlag |  Description |
+----+------------+-------------+-------------+---------------+
|  1     | Paper    | Cabinet     |  0             | Blah            |
|  2     | Plastic   | Cabinet     |  0             | Blah            |
|  3     | China    | Cabinet     |  1             | Blah            |
|  4     | Glass    | Cabinet     |  0             | Blah            |
|  5     | China    | Table         |  0             | Blah            |
|  6     | China    | Cabinet     |  1             | Blah            |
+----+------------+-------------+-------------+---------------+

Is there a way to, using a single query, set the OnOffFlag to 1 for
the record that matches [Name=China AND Location=Table] at the same
time setting the OnOffFlag to 0 for records that match [Name=China AND
Location!=Table]?  I know I can do it in 2 queries but I am curious to
know if it can actually be done in 1.

thnx,
Chris
Thread
UPDATE jujitsu?Christoph Boget8 Jan
  • Re: UPDATE jujitsu?Jim Lyons8 Jan