我有一个会返回值的查询,但我需要将它们作为用逗号分隔的单个输出..
所以我尝试用逗号连接输出,但它不起作用?
select id from videos where duration=0; /// this would return some rows
我尝试了 concat 和 concat_ws 但没有用
select concat(select concat(id,',') from videos where duration=0);
select concat((select id from videos where duration=0),',');
select concat_ws(',',(select id from videos where duration=0));
我需要所有行的 id 和逗号分隔符
例如输出应该是 1,4,6,78,565
有什么想法吗?
最佳答案
这就是 group_concat可以。
select group_concat(id) as video_list
from videos
where duration=0
关于mysql - 连接子查询的输出?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3812864/