Jump to content

Recommended Posts

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



Link to comment
https://forums.phpfreaks.com/topic/3255-query-construction/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.