Re: select a list of column values directly into an array

From: Yeb Havinga <yebhavinga(at)gmail(dot)com>
To: "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select a list of column values directly into an array
Date: 2010-07-27 13:20:17
Message-ID: 4C4EDD11.2090300@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A. Kretschmer wrote:
> In response to Gauthier, Dave :
>
>> Is there a way to select a list of column values directly into an array?
>>
>>
>>
>> create table foo (col1 text);
>>
>> insert into foo (col1) values (?aaa?),(?bbb?),(?ccc?),(?ddd?),(?eee?);
>>
>>
>>
>> I?d like to load up an array with {aaa,bbb,ccc,ddd,eee}, prefferably with a
>> single select statement.
>>
>
> test=*# select array_agg(col1) from foo;
> array_agg
> -----------------------
> {aaa,bbb,ccc,ddd,eee}
>
/me scratches on head - wasn't there something with array?

select ARRAY (select col1 from foo);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Yeb Havinga 2010-07-27 13:21:15 Re: select a list of column values directly into an array
Previous Message A. Kretschmer 2010-07-27 13:09:39 Re: select a list of column values directly into an array