如何通过SELECT返回不止一行的数组 [英] How to make an array from a SELECT returning more than one row
本文介绍了如何通过SELECT返回不止一行的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以从查询中制作一个大数组,例如:
Is it possible to make one big array from a query like:
select
array_append(ARRAY[0], console_id)
from archive_sessions
where tournament_id = 14817
group by
,但是我必须在其中使用console_id,它仍然超过1行。
I tried with group by
but I have to use console_id in it and it still is more than 1 row.
以及如何输入此查询初始化一个空的 ARRAY []
?
And how in this query initializing an empty ARRAY[]
?
推荐答案
您要< a href = http://www.postgresql.org/docs/current/static/functions-aggregate.html rel = nofollow> array_agg
select array_agg(console_id) as consoles from archive_sessions where tournament_id = 14817
这篇关于如何通过SELECT返回不止一行的数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文