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

Using Array-Values in subselect

From: Alvar Freude <alvar(dot)freude(at)merz-akademie(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: Using Array-Values in subselect
Date: 2000-11-14 20:51:59
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

i want to create a linked structure of values. Each text has an id, an
array of children ids and the value itself.

  CREATE TABLE structure
    id int8,
    children int8[],
    value text

Now i want to select all values which are connected to a given parent #x
at once. My first idea was this:

  SELECT value 
  FROM structure
     WHERE id IN (SELECT children FROM structure WHERE id = #x);

But this causes an error because the array field just returns a string
instead of seperated values. Is there a way to make arrays return sort
of "real arrays" or something usable in a subselect in reasonable speed?

Thank you

Alvar C.H. Freude  |  alvar(dot)freude(at)merz-akademie(dot)de

    Demo:  |  Mach mit!
Blast-DE:   |  Blast-Dich-Fit
Blast-EN:               |  Blast/english


pgsql-sql by date

Next:From: Roberto MelloDate: 2000-11-14 21:15:11
Subject: Re: Using Array-Values in subselect
Previous:From: Marten FeldtmannDate: 2000-11-14 20:11:49
Subject: Re: Using a postgres table to maintain unique id?

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