表A 表B
需要的结果:
第一步:运用 for xml path 和 charindex
select A.id,(
select ','+B.name from B
where charindex( ','+B.code , ','+A.code+',')>0
order by B.code
for xml path('')
)
from A
结果:
charindex :
表A 表B
需要的结果:
第一步:运用 for xml path 和 charindex
select A.id,(
select ','+B.name from B
where charindex( ','+B.code , ','+A.code+',')>0
order by B.code
for xml path('')
)
from A
结果:
charindex :