| From: | Keith Gray <keith(at)heart(dot)com(dot)au> |
|---|---|
| To: | Jason Kwok <jason(at)newhonest(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: Recursive select |
| Date: | 2001-10-29 22:09:31 |
| Message-ID: | 3BDDD39B.89A2A19C@heart.com.au |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | 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(at)heart(dot)com(dot)au
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Roberto Mello | 2001-10-29 22:47:54 | Re: Recursive select |
| Previous Message | Greg Sabino Mullane | 2001-10-29 20:49:40 | Re: Deletion Recursively |