Re: Recursive select - Mailing list pgsql-sql

From Keith Gray
Subject Re: Recursive select
Date
Msg-id 3BDDD39B.89A2A19C@heart.com.au
Whole thread Raw
In response to Recursive select  ("Jason Kwok" <jason@newhonest.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: "Greg Sabino Mullane"
Date:
Subject: Re: Recursive select
Next
From: "Greg Sabino Mullane"
Date:
Subject: Re: Deletion Recursively