急:mysql怎么实现sqlserver中for xml path

急:mysql怎么实现sqlserver中for xml path,第1张

mysql中有group_concat()()可以合并多行内容select AID,ANAME,(select group_concat(VALUE) from B where B.AID=A.AID) as AVALUE from A

(1) select b,b+'('+stuff((select ','+a from tab t2 where t2.b=t1.b for xml path('')),1,1,'')+')' as result from tab t1 group by b

(2) select b,'('+stuff((select ','+a from tab t2 where t2.b=t1.b for xml path('')),1,1,'')+')' as result from tab t1 group by b

(3) select b+'('+stuff((select ','+a from tab t2 where t2.b=t1.b for xml path('')),1,1,'')+')' as result from tab t1 group by b

看哪个你要的。

至于为什么可以这样,请百度T-SQL的for xml path。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7172565.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-02
下一篇 2023-04-02

发表评论

登录后才能评论

评论列表(0条)

保存