need help with a sql query
Posted: Thu Mar 16, 2006 10:40 am
I'm quite inexperienced in mysql so this one has me stumped. The mission, should you care to accept it, is as follows:
A database of, oh lets be classical and say, Widgets.
Table : widgets.
Columns: widget_id,widget_name
Sample data:
1,SnazzyWidget
2,SleepyWidget
Table: widget_attributes
Columns: attribute_id, attribute_name
Sample data:
1, Can fly
2, Can talk
3, Multi-coloured
4, Executive class
Table: attribute_map
Columns: widget_id, attribute_jd
Sample data:
1,1
1,4
1,3
2,3
I hope you get the picture. attribute_map maps the two other tables together. A widget can have more than one attribute, as in the sample SnazzyWidget can fly, is multi-coloured and is Executive class.
I am able to list what attributes each widget has on its relevant Widget Page. But in the admin page I must print a list of widget attributes with checkboxes next to them, and the box is checked if the widget in question has that particular attribute. This is just beyond my level of SQL. Can anyone offer me a hint?
A database of, oh lets be classical and say, Widgets.
Table : widgets.
Columns: widget_id,widget_name
Sample data:
1,SnazzyWidget
2,SleepyWidget
Table: widget_attributes
Columns: attribute_id, attribute_name
Sample data:
1, Can fly
2, Can talk
3, Multi-coloured
4, Executive class
Table: attribute_map
Columns: widget_id, attribute_jd
Sample data:
1,1
1,4
1,3
2,3
I hope you get the picture. attribute_map maps the two other tables together. A widget can have more than one attribute, as in the sample SnazzyWidget can fly, is multi-coloured and is Executive class.
I am able to list what attributes each widget has on its relevant Widget Page. But in the admin page I must print a list of widget attributes with checkboxes next to them, and the box is checked if the widget in question has that particular attribute. This is just beyond my level of SQL. Can anyone offer me a hint?