select bankCard=(select b.BankCardNumber+',' from C_BankCard as b where b.UserId=r.UserId FOR XML PATH('')),* from [C_User_Register] r where r.UserId='101457'
select CONCAT(b.BankCardNumber,',',b.BankName) from C_BankCard as b where b.UserId='101457' -- SQLSERVER 2017 版本 select STRING_AGG(b.BankCardNumber,',') from C_BankCard as b where b.UserId='101457'
select *,STUFF((select BankCardNumber+',' from C_BankCard FOR XML PATH('')),1,1,'' ) as t from C_BankCard
标签:BankCardNumber,合并,BankCard,101457,where,SQLSERVEL,UserId,数据,select
From: https://blog.51cto.com/jition/6402884