Bootstrap

[SQLServer]将多条记录的一个字段进行连接

for xml path('root')



select tt.organization_id, left(list,len(list)-1) from (
select t.organization_id,(
select cast(party_id as varchar) + ','
from hrs_employee for xml path('')
) as list
from hrs_employee t group by t.organization_id
) tt



1 0,0,1,1,8000001000002,8000001000003
99 0,0,1,1,8000001000002,8000001000003
;