i'm trying to construct what i believe would be a fairly simple query against 1 table with just 3 columns. however, with my limited sql knowledge, it feels like i'm going in circles. can any mysql gurus please help?
my table is called "categories" and has the following fields and example data:
product_id category_name category_value
---------- ------------- --------------
widget1 type square
widget1 item engineering
widget1 color black
widget2 type round
widget2 color red
widget2 item engineering
widget3 item chemical
widget4 item chemical
widget4 color red
each product can be assigned 1 to n categories and this table will hold the relationships (may not be a de-normalized table, but for my use, it seemed the best design). for example, widget1 is a black, square, engineering widget, and widget4 is a red, chemical widget.
ok, all i want to be able to do is create a list of all available category_values given a category_value selection. For example, if "red" has been selected, show the category_values of "round," "engineering," and "chemical," since the "red" widgets (widget2 and widget4) have been assigned the additional category values of "round," "engineering," and "chemical." Does this make sense?
i believe this can be done using SUB-SELECTS, but since i don't have mysql 4.1, sub-selects are unfortunately not an option.
i know i have to missing something simple here, right? can anyone help?
thanks in advance for your input!
my table is called "categories" and has the following fields and example data:
product_id category_name category_value
---------- ------------- --------------
widget1 type square
widget1 item engineering
widget1 color black
widget2 type round
widget2 color red
widget2 item engineering
widget3 item chemical
widget4 item chemical
widget4 color red
each product can be assigned 1 to n categories and this table will hold the relationships (may not be a de-normalized table, but for my use, it seemed the best design). for example, widget1 is a black, square, engineering widget, and widget4 is a red, chemical widget.
ok, all i want to be able to do is create a list of all available category_values given a category_value selection. For example, if "red" has been selected, show the category_values of "round," "engineering," and "chemical," since the "red" widgets (widget2 and widget4) have been assigned the additional category values of "round," "engineering," and "chemical." Does this make sense?
i believe this can be done using SUB-SELECTS, but since i don't have mysql 4.1, sub-selects are unfortunately not an option.
i know i have to missing something simple here, right? can anyone help?
thanks in advance for your input!