I've looked around for quite a while to try and find the answer to my specific issue but I'm not having any luck.
I'm using the following code to export to an XML Path:
SELECT
productid, title,
(SELECT colors + ' '
FROM dbo.productdetails
WHERE (active = 1)
AND (productid = j.productid)
GROUP BY colors
FOR XML PATH('')) AS 'color_tags'
FROM
dbo.jewelry AS j
I have a group by applied and it's working but it's viewing things like "black blue" and "black green" as entire values so basically I'm getting duplicate words when it outputs the XML. I've also tried DISTINCT but it does the exact same thing.
I have some data stored in a table like this:
+-----------+-------------+
| productid | color_tags |
+-----------+-------------+
| 1 | black |
| 1 | black blue |
| 1 | black green |
| 1 | blue green |
| 1 | black |
+-----------+-------------+
The data I want to have on a single line is like this (basically no duplicate values):
black, blue, green
But what I'm getting is this:
black, black blue, black green, blue green
Any help would be appreciated, thank you!