I have 2 tables, tblParts and tblAttributes. Each row in tblAttributes has a column that links to tblParts, an attribute name, and a value. Here is some sample data:
tblParts
ID Desc
1 Small Widget
2 Medium Widget
3 Large Widget
tblAttributes
ID PartID Attribute Desc
1 1 Color Blue
2 1 Weight 1 Pound
3 1 UPC 123456789
4 2 Color Yellow
5 2 Weight 2 Pounds
6 3 Color Red
7 3 UPC 345667788
I need to produce a view that shows the following:
ID Desc Color Weight UPC
1 Small Widget Blue 1 Pound 123456789
2 Medium Widget Yellow 2 Pounds
3 Large Widget Red 345667788
I was able to do this as a view by bringing in aliases of tblAttibutes and setting a WHERE clause to equal the name of the attribute name so I only get returned the colors returned for that alias. I then put it into a column w/ an alias named "Color".
I don't think it's the most efficient as if more attributes are added later, I won't have them available unless I change the view.
Does anyone have any ideas?
Thanks!
Ed
tblParts
ID Desc
1 Small Widget
2 Medium Widget
3 Large Widget
tblAttributes
ID PartID Attribute Desc
1 1 Color Blue
2 1 Weight 1 Pound
3 1 UPC 123456789
4 2 Color Yellow
5 2 Weight 2 Pounds
6 3 Color Red
7 3 UPC 345667788
I need to produce a view that shows the following:
ID Desc Color Weight UPC
1 Small Widget Blue 1 Pound 123456789
2 Medium Widget Yellow 2 Pounds
3 Large Widget Red 345667788
I was able to do this as a view by bringing in aliases of tblAttibutes and setting a WHERE clause to equal the name of the attribute name so I only get returned the colors returned for that alias. I then put it into a column w/ an alias named "Color".
I don't think it's the most efficient as if more attributes are added later, I won't have them available unless I change the view.
Does anyone have any ideas?
Thanks!
Ed