标签:src inner for join img where 字符串 alt 部门
Department表
Employee表
查询结果:
查询每个部门的人员名称
dbo.View_1:
SELECT dbo.Department.DepName, dbo.Employee.EmpName
FROM dbo.Department INNER JOIN
dbo.Employee ON dbo.Department.DepID = dbo.Employee.DepID
查询:
select DepName,STUFF((select ‘,‘+ EmpName from dbo.View_1 where dbo.View_1.DepName=b.DepName for xml path(‘‘)),1,1,‘‘)as name
from dbo.View_1 as b group by DepName
标签:src inner for join img where 字符串 alt 部门
原文地址:http://www.cnblogs.com/qiaoyl/p/stuff_for_xml_path.html