SQL将某一字段多条记录合并为一个字段显示

 

select namelist=STUFF(REPLACE(REPLACE(( SELECT ID FROM [LotteryMatch] where GameDateTime > getdate() FOR XML AUTO ), '<LotteryMatch ID="', ','), '"/>', ''), 1, 1, '') from [LotteryMatch]

select namelist=STUFF(REPLACE(REPLACE(( SELECT ID FROM [LotteryMatch] where GameDateTime > getdate() FOR XML AUTO ), '<LotteryMatch ID="', ','), '"/>', ''), 1, 1, '') from [LotteryMatch]

 

你可能感兴趣的:(sql)