Jump to content

Merging Multiple Queries


jwwceo

Recommended Posts

I have this query(below), which I am using to update a field in my database. I am doing this in phpMyAdmin. But I have to run it 17 times, once for each color, times and would like to merge all queries into one so in the future I can run it just once.

 

Here's an individual query:

 

UPDATE xcart_variants, xcart_class_options, xcart_variant_items

SET xcart_variants.color_id ='ffffff'
WHERE xcart_variants.variantid = xcart_variant_items.variantid
AND xcart_variant_items.optionid = xcart_class_options.optionid
AND xcart_class_options.option_name = 'Black'

 

and here's what I have for a multiple query:

 

UPDATE xcart_variants, xcart_class_options, xcart_variant_items

SET xcart_variants.color_id ='432c00'
WHERE xcart_variants.variantid = xcart_variant_items.variantid
AND xcart_variant_items.optionid = xcart_class_options.optionid
AND xcart_class_options.option_name = 'Brown'

SET xcart_variants.color_id ='020950'
WHERE xcart_variants.variantid = xcart_variant_items.variantid
AND xcart_variant_items.optionid = xcart_class_options.optionid
AND xcart_class_options.option_name = 'Navy'

SET xcart_variants.color_id ='000000'
WHERE xcart_variants.variantid = xcart_variant_items.variantid
AND xcart_variant_items.optionid = xcart_class_options.optionid
AND xcart_class_options.option_name = 'Black'

SET xcart_variants.color_id ='ffffff'
WHERE xcart_variants.variantid = xcart_variant_items.variantid
AND xcart_variant_items.optionid = xcart_class_options.optionid
AND xcart_class_options.option_name = 'White'

 

Any ideas why I am getting errors??

 

James

Link to comment
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.