Skip site navigation (1) Skip section navigation (2)

Re: Turning a subselect into an array

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: "Jim C(dot) Nasby" <decibel(at)decibel(dot)org>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Turning a subselect into an array
Date: 2004-10-30 04:40:57
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-docspgsql-general
On Fri, Oct 29, 2004 at 05:13:02PM -0500, Jim C. Nasby wrote:
> 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?

See the "Subquery Expressions" and "Row and Array Comparisons"
sections in the PostgreSQL documentation:

If I understand you correctly, this should work:


A test I just ran showed "id = ANY(ARRAY[1,2,3])" doing a sequential
scan whereas "id IN (1,2,3)" did an index scan, so you might want to
use the latter if possible.

Michael Fuhr

In response to


pgsql-docs by date

Next:From: Jim C. NasbyDate: 2004-10-30 06:07:37
Subject: Re: [GENERAL] Turning a subselect into an array
Previous:From: Jim C. NasbyDate: 2004-10-29 22:13:02
Subject: Re: Turning a subselect into an array

pgsql-general by date

Next:From: Russell SmithDate: 2004-10-30 06:02:34
Subject: Re: QMail
Previous:From: Tom LaneDate: 2004-10-30 01:59:17
Subject: Re: 8.0 Beta 4 denying network connections?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group