stuff
按CategoryID分组并排序,Names为相同的CategoryID的PropertyXngName以‘,’连接
select t.CategoryID,Names = stuff((select ',' +c.PropertyXngName from [develop].[dbo].[Xng_Properties] c where t.CategoryID = c.CategoryID for XML path('')) , 1 , 1 , '') from [develop].[dbo].[Xng_Properties] t Group by t.CategoryID order by t.CategoryID
浙公网安备 33010602011771号