From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Adrian von Bidder <avbidder(at)fortytwo(dot)ch> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Q: Tree traversal with SQL query? |
Date: | 2007-06-15 08:49:44 |
Message-ID: | 467252A8.5060505@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Adrian von Bidder wrote:
> Hi,
>
> Is there any way to do tree traversal with only one SQL query (no
> procedure/function)?
>
> CREATE TABLE foo (
> node INTEGER,
> parent INTEGER REFERENCES foo(node)
> );
>
> Ideally the output would be a depth-first tree traversal starting at root
> (marked by parent == node, for example.)
>
> Obviously, I can do this with "normal" programming and loops, but it bugged
> me a while if its at all possible doing this in one query.
Have a look at contrib/ltree ;)
--
Alban Hertroys
alban(at)magproductions(dot)nl
magproductions b.v.
T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
7500 AK Enschede
// Integrate Your World //
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Stark | 2007-06-15 08:57:33 | Re: DeadLocks..., DeadLocks... |
Previous Message | Gregory Stark | 2007-06-15 08:49:31 | Re: pg_restore out of memory |