mysql中选定值的逗号分隔字符串

2021-11-20 00:00:00 select comma mysql

我想在 MySQL 中将选定的值转换为逗号分隔的字符串.我的初始代码如下:

I want to convert selected values into a comma separated string in MySQL. My initial code is as follows:

SELECT id FROM table_level where parent_id=4;

产生的:

'5'
'6'
'9'
'10'
'12'
'14'
'15'
'17'
'18'
'779'

我想要的输出如下所示:

My desired output would look like this:

"5,6,9,10,12,14,15,17,18,779"

推荐答案

检查这个

SELECT GROUP_CONCAT(id)  FROM table_level where parent_id=4 group by parent_id;

相关文章