Hi,
I hope someone here can help me.
We have a product table which has a many-to-many relation
to a category table (joined through a third "ProductCategor y" table):
[product] ---< [productCategory] >--- [category]
--------- ---------------- ----------
productID productCategory ID categoryID
productName productID categoryName
categoryID
We want to get a view where each product occupies just one row, and
any multiple category values are combined into a single value, eg
(concatenating with commas):
Product Category
-------------------
cheese dairy
cheese solid
milk dairy
milk liquid
beer liquid
will become:
Product Category
-------------------
cheese dairy, solid
milk dairy, liquid
beer liquid
What is the best way to do it in SQL?
Thanks and regards,
Dmitri
I hope someone here can help me.
We have a product table which has a many-to-many relation
to a category table (joined through a third "ProductCategor y" table):
[product] ---< [productCategory] >--- [category]
--------- ---------------- ----------
productID productCategory ID categoryID
productName productID categoryName
categoryID
We want to get a view where each product occupies just one row, and
any multiple category values are combined into a single value, eg
(concatenating with commas):
Product Category
-------------------
cheese dairy
cheese solid
milk dairy
milk liquid
beer liquid
will become:
Product Category
-------------------
cheese dairy, solid
milk dairy, liquid
beer liquid
What is the best way to do it in SQL?
Thanks and regards,
Dmitri
Comment