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:21:15
Message-ID: 4C4EDD4B.9020907@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}
>
Or select ARRAY (select col1 from foo);

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Merlin Moncure 2010-07-27 13:25:23 Re: select a list of column values directly into an array
Previous Message Yeb Havinga 2010-07-27 13:20:17 Re: select a list of column values directly into an array