From: Keith Gray <keith@heart.com.au>
To: Jason Kwok <jason@newhonest.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Recursive select
Date: Tue, 30 Oct 2001 09:09:31 +1100
Message-ID: <3BDDD39B.89A2A19C@heart.com.au> (raw)
References: <00af01c15deb$74289940$0201a8c0@newhonest.com>
Jason Kwok wrote:
>
> I have a table :
>
> MyID parentID
> ================
> 5 6
> 6 7
> 3 13
> 7 3
>
> Is there any simple select statement that can get all rows with MyID = 5 and
> all its parents?
> That means 5's parenet is 6, 6's parent is 7, 7's parent is 3.....
>
I had a similar problem a couple of weeks back.
The only way I could get around it was "programmatically".
This is an iterative (loop) problem.
Because I am writing for several brands/flavours of database
I solved it in VB, but some solutions (for postgres only)
are offered using functions or triggers in PgSQL.
--
Keith Gray
Technical Development Manager
Heart Consulting Services P/L
mailto:keith@heart.com.au
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: keith@heart.com.au, jason@newhonest.com
Subject: Re: Recursive select
In-Reply-To: <3BDDD39B.89A2A19C@heart.com.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox