I have three tables. Table A has the option name (i.e. Color, Size). Table B has option value name (i.e Blue, Red, Black, Etc.). Table C establishes the relationship by putting option name id and option name value id together in a row.
My query needs to show the names of the values and and options as opposed to the id number. I can do A and B one at a time and get a list of value and options names, but since the value and options are related I want a combined list. For Example.
Color – Blue
Color – Red
Size – Big
Size – Small
So my question is how to join these two queries to get a combined result like above.
SELECT products_options.products_options_name FROM products_options
LEFT JOIN products_options_values_to_products_options ON products_options_values_to_products_options.products_options_id=products_options.products_options_id
SELECT products_options_values.products_options_values_name FROM products_options_values
LEFT JOIN products_options_values_to_products_options ON products_options_values_to_products_options.products_options_values_id=products_options_values.products_options_values_id
You need two joins, which will look like this:
It won’t combine them together for an immediate insert in your variations table, but this is the best you’ll do in MySQL.