sqlServer 合并多个结果,以逗号隔开

select mid,stuff((select distinct ','+uid from t1 where a.mid=mid for xml path('')),1,1,'') AS items
from t1 a group by mid


结果
mid items
1  a,b,c,d
2  a,b,c
3  a,b,c

 

posted @ 2022-04-12 10:34  Li_ll  Views(306)  Comments(0Edit  收藏  举报