Ok, next stupid question that I can't find in the docs... How would I
join a table to an array? IE: if I have an array of primary keys for
some table and I want to get the name field from that table and turn it
back into an array, how would I do that?
On Thu, Oct 28, 2004 at 05:21:52PM -0600, Michael Fuhr wrote:
> On Thu, Oct 28, 2004 at 05:37:29PM -0500, Jim C. Nasby wrote:
> > I'm sure this has been answered before, but the search seems to be down
> > again.
> > How can I convert the results of a subselect into an array? IE:
> > CREATE TABLE a(a int, b int, c int);
> > INSERT INTO table_a
> > SELECT a, b, (SELECT c FROM table_c WHERE table_c.parent = table_b.id)
> > FROM table_b
> See the "Array Constructors" section in the PostgreSQL documentation:
> INSERT INTO table_a
> SELECT a, b, ARRAY(SELECT c FROM table_c WHERE table_c.parent = table_b.id)
> FROM table_b
> Michael Fuhr
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
Jim C. Nasby, Database Consultant decibel(at)decibel(dot)org
Give your computer some brain candy! www.distributed.net Team #1828
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"
In response to
pgsql-docs by date
|Next:||From: Michael Fuhr||Date: 2004-10-30 04:40:57|
|Subject: Re: Turning a subselect into an array|
|Previous:||From: Tom Lane||Date: 2004-10-29 19:41:10|
|Subject: Re: PREPARE statement example error. |
pgsql-general by date
|Next:||From: Tom Lane||Date: 2004-10-29 22:27:46|
|Subject: Re: XMIN/xid vs UNION |
|Previous:||From: Martijn van Oosterhout||Date: 2004-10-29 21:54:05|
|Subject: Re: column updates|