Jump to content


Photo

Query Construction


  • Please log in to reply
1 reply to this topic

#1 Michael

Michael
  • Members
  • Pip
  • Newbie
  • 5 posts

Posted 25 January 2006 - 10:06 PM

Hello

What I am trying to solve is as follows:

I have a table that contains three fields that record preferences of user car models selected from a fixed list of car makes. Although the list is finite, any field can contain any member of the car make list.

I want the ability to delete a car from the list. When I do that I want to go thru the table and replace the deleted car model with "empty"

I know I can do with with three queries, but am trying to figure out if I can do it with one query. I've been researching on the 'net but am not coming up with an answer.

What I would like to do is something like

UPDATE TABLE SET (field 1 = "empty" WHERE field 1 = 'toyata"),
(field 2 = "empty" WHERE field 2 = 'toyata"),
(field 3 = "empty" WHERE field 2 = 'toyata")
WHERE userid = "id";

I suppose my example is absurd but it gives the idea of what I want to do if possible.

Or just use three queries.

I would appreicate any comments.

Thanks





#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 25 January 2006 - 10:29 PM

See my response [a href=\"http://www.mysqlfreaks.com/forums/index.php?showtopic=8984&st=0&\" target=\"_blank\"]on this MySQLFreaks.com cross-post thread[/a].
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users