我想在MySQL中将选定的值转换为逗号分隔的字符串。我的初始代码如下:
SELECT id FROM table_level where parent_id=4;
哪个产生了:
'5' '6' '9' '10' '12' '14' '15' '17' '18' '779'
我想要的输出看起来像这样:
"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;