我正在使用 XML PATH 绑定多值列,查询工作正常,但结果是 xml 格式,我想将其转换为简单文本这是查询
SELECT soo.order_id,
sum(oo.total)AS total,
items=(SELECT si.item_name FROM sub_order i,Items si
WHERE i.order_id=soo.order_id and si.item_id=i.item_id FOR XML PATH(''))
FROM Orders oo
INNER JOIN Sub_Order soo ON oo.order_id = soo.order_id
INNER JOIN Items
ON soo.item_id = Items.item_id
group by soo.order_id
“项目”字段的结果就像
<item_name>cake</item_name><item_name>soap</item_name>
但我希望它像 cake,soap