mssql的 for xml path 与 mysql中的group_concat类似MSSQL For xml Path
/****** Script for SelectTopNRows command from SSMS ******/
SELECT D_ID,[D_Name] as Name FROM [LFBMP.LDS].[dbo].[LDS.Dictionary] Where '32,33,34,35' like '%'+convert(nvarchar(10),D_ID)+'%' FOR XML PATH
SELECT [D_Name]+',' FROM [LFBMP.LDS].[dbo].[LDS.Dictionary] Where '32,33,34,35' like '%'+convert(nvarchar(10),D_ID)+'%' FOR XML PATH('row')
SELECT [D_Name]+',' FROM [LFBMP.LDS].[dbo].[LDS.Dictionary] Where '32,33,34,35' like '%'+convert(nvarchar(10),D_ID)+'%' FOR XML PATH('')
SELECT [D_Name],D_ID FROM [LFBMP.LDS].[dbo].[LDS.Dictionary] Where ',32,33,34,35,' like '%'+convert(nvarchar(10),D_ID)+'%'
Select CompanyID,CompanyNameCN,CompanyNameEN,CompanyTypeIDStr
,(Select group_concat(TypeNameCN SEPARATOR ',') from com_companytype where concat(',',t1.CompanyTypeIDStr,',') like CONCAT('%,',CONCAT(CompanyTypeID),',%')) as CompanyTypeIDStrName
from com_company as t1
-- 类似MSSQL For xml Path
-- Select group_concat(TypeNameCN) from com_companytype where ',1,2,3,' like CONCAT('%',CONCAT(CompanyTypeID),'%')
欢迎加入JAVA技术交流QQ群:179945282
欢迎加入ASP.NET(C#)交流QQ群:17534377