Jump to content

Recommended Posts

I am trying to write a JOIN query but it doesn't seem to be working. I get error, #1109, saying that one of my tables doesn't exist.

 

Plus, once I get this working, I am a but confused how I can pass a criteria into this query since I am assuming that would also be done in the WHERE clause.

 

Best,

 

James

 

SELECT xcart_variants.color_id FROM xcart_variants 
WHERE

xcart_class_options.optionname
xcart_variants.variantid = xcart_variant_items.variantid
AND
xcart_variant_items.optionid = xcart_class_options.optionid

Link to comment
https://forums.phpfreaks.com/topic/78117-tricky-little-query/
Share on other sites

  SELECT
    v.`color_id`
  FROM `xcart_variants` v
  INNER JOIN `xcart_variant_items` i ON v.`variantid`=i.`variantid`
  INNER JOIN `xcart_class_options` o ON i.`optionid`=o.`optionid`
  WHERE
    o.optionname='some option'

Link to comment
https://forums.phpfreaks.com/topic/78117-tricky-little-query/#findComment-395322
Share on other sites

Do you mean color.id or color_id?  There is a big difference.

 

UPDATING and SELECTING are two different things.  Are you trying to run a single query to update color_id in multiple tables?  If so, which tables do you want to update?

Link to comment
https://forums.phpfreaks.com/topic/78117-tricky-little-query/#findComment-395381
Share on other sites

To simplify the problem, we want to change a hex color value in a table based on the text value (ie. Black) that is in another table. These tables do not relate to one another, except through a third table.

 

The table/field we are trying to update is: xcart_variants.color_id

based on criteria in this table: class_options.optionname

 

The value we wish to change it to will change from time to time, so for purposes of this thread, I suppose we can just use a variable "FFFFFF".

 

Best,

 

James

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/78117-tricky-little-query/#findComment-395773
Share on other sites

In addition to my last post...this is what I have been trying and getting errors on:

 

UPDATE xcart_variants SET color_id ='ffffff'

INNER JOIN xcart_variant_items.variantid ON xcart_variants.variantid
INNER JOIN xcart_class_options.optionid ON xcart_variant_items.optionid

WHERE

xcart_class_options.option_name = 'Black'

Link to comment
https://forums.phpfreaks.com/topic/78117-tricky-little-query/#findComment-395784
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.