--create table tb(ShopName nvarchar(30),food nvarchar(30)) ----drop table tb --insert into [tb] --select '澳门豆捞','川菜' union all --select '澳门豆捞','粤菜' union all --select '澳门豆捞','闽菜' union all --select '为民大酒店','鲁菜' union all --select '为民大酒店','粤菜' union all --select '为民大酒店','川菜' -------结果如下------------- --店名 菜系---------- --澳门豆捞 川菜,闽菜,粤菜 --为民大酒店 川菜,鲁菜,粤菜 ---------------------------- SELECT SHOPNAME,FOOD=STUFF((SELECT ','+FOOD FROM TB T WHERE T.ShopName=tb.ShopName FOR XML PATH('')),1,1,'') FROM tb GROUP BY ShopName