jwwceo Posted November 24, 2007 Share Posted November 24, 2007 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 https://forums.phpfreaks.com/topic/78678-merging-multiple-queries/ Share on other sites More sharing options...
fenway Posted November 24, 2007 Share Posted November 24, 2007 You can't do multiple queries... just build a hash in php and run it in a loop. You could do this in mysql directly with a bunch of case statements, but what's thepoint? Link to comment https://forums.phpfreaks.com/topic/78678-merging-multiple-queries/#findComment-398195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.