I have some tables in SQL Server 2005:
Product
:ID, Name
Category
:ID, Name
Tags
:ID, tagName
ProductCategory
:productId, tagId
CategoryTags
:categoryId, tagId
Basically I need a query that will display the category and list of tags associated for each product on ONE line.
For example, there are 3 categories: Animals, Countries, Color
.
Each one of those have a bunch of tags.
Lets say that Product 1 has a bunch of tags associated such as: bird, duck, dog, canada, russia, japan, black, red, white
I need the query result to be in the format:
productId, [Category:tag,tag,tag;Category:tag,tag,tag:Category:tag,tag,tag]
1, [Animal:bird,duck,dog;Country:canada,russia,japan;Color:black,red,white]
The text in the square brackets should be in one column returned by SQL.
I found something similar here: Concatenate many rows into a single text string?
But I need to take it a step further and have it all on one line instead of it returning the different categories on separate rows.
Kinda hard to explain but hope you get it.
Is this possible?
Thanks in advance.
UPDATE: Thanks for everyone's help and input. Really appreciate it! Here is what I have so far which is close, but not quite there yet. Perhaps it'll help you figure it out for me :D