gpt4 book ai didi

mysql - 连接子查询的输出?

转载 作者:IT老高 更新时间:2023-10-28 23:45:52 26 4
gpt4 key购买 nike

我有一个会返回值的查询,但我需要将它们作为用逗号分隔的单个输出..

所以我尝试用逗号连接输出,但它不起作用?

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com