Mysql bosses, how can you tell me how to output select "1 Magi 2 Jing 3 Jing 4 Jing 5" as comma-separated results?

I want to output a comma-separated string 1 br 2 3 4 5 as
clipboard.png

select "1,2,3,4,5"

clipboard.png

Mar.28,2021

--SQL
DECLARE @s VARCHAR(100)
DECLARE @sql VARCHAR(1000)
SET @s='1,2,3,4,5'
SET @sql='SELECT NewColumn='''+REPLACE(@s,',','''UNION ALL SELECT ''')+''''
PRINT @sql
EXEC (@sql)

learn more


mysql character stitching can be understood, if you want to group, and then let the data stitching into characters can use the group_concat function, the rest of their own understanding, according to the needs of the choice.

Menu