实现:使用for xml path(‘’) 和stuff
效果:
sql语句
SELECTstuff(( SELECT ',' + su.user_name FROM sys_user su WHERE su.user_id IN ( '87', '86' ) FOR xml path ( '' ) ),1,1,'' ) AS user_name
来源地址:https://blog.csdn.net/fortunate_leixin/article/details/128130130