I have a query like this:
SELECT
MCU.UserName
,MCU.McUserId AS UserId
,O.OrderId
,PD.ProductId
,O.ShippingId
,PD.[Name] AS ProductName
,O.OrderDate
,O.Total
,O.Subtotal
,O.PaymentStatus
,O.OrderNumber
,O.[Type]
,O.CreatedBy
,O.ModifiedBy
FROM SecurityMc.McUsers AS MCU
INNER JOIN Store.[Order] AS O ON MCU.McUserId = O.UserId
INNER JOIN Store.OrderItem AS OI ON O.OrderId = OI.OrderId
INNER JOIN Customer.Shipping AS CS ON O.ShippingId = CS.ShippingId
INNER JOIN Product.ProductDetail AS PD ON OI.ProductId = PD.ProductId
WHERE O.[Type] = 'Order' AND O.IsDeleted = 0 AND 1 = LanguageId
It returns data like:
+--------+---------+-----------+-------------+
| UserId | OrderId | ProductId | ProductName |
+--------+---------+-----------+-------------+
| 1 | 3 | 1 | Dress |
| 1 | 3 | 2 | Boots |
| 1 | 3 | 3 | Socks |
| 1 | 3 | 4 | Extension |
+--------+---------+-----------+-------------+
As you can see it returns one ProductName for each row, but I want to send it in just one array, as you can see it have same OrderId and UserId, its possible to concat ProductName if OrderId is the same and get something like:
ProductName(1 column): Dress,Boots,Socks,Extension
How can I achieve it? Regards