我在其中一个问题中 学习sql,在这里我看到了这个用法,有些机构能让我理解xml路径('')在sql中的含义吗?是的,我通过网页浏览,我不太了解它!
我没有得到东西,现在这段代码做了什么?(只是select部分)
declare @t table
(
Id int,
Name varchar(10)
)
insert into @t
select 1,'a' union all
select 1,'b' union all
select 2,'c' union all
select 2,'d'
select ID,
stuff(
(
select ','+ [Name] from @t where Id = t.Id for XML path('')
),1,1,'')
from (select distinct ID from @t )t
Run Code Online (Sandbox Code Playgroud)