From: | "Paul Skinner" <skin(at)skin(dot)dhs(dot)org> |
---|---|
To: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Determining parent. |
Date: | 2001-01-05 17:43:02 |
Message-ID: | 005f01c0773e$f3756a50$03320a0a@skinz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Greetings to all.
This is more of a SQL question than a direct PostgreSQL question.
Say I have 1 table... Objects has columns IDX int, Parent int, Deleted bit, I have the objects table loaded with data, some records will have a Parent record that references the IDX of the object table. Given one object, how can I determine all the whole tree of all sub-objects and not just the first child?
IE, below. Say I want to know all objects under IDX 1, no problem, but how do I then drill down the query to get all children? I did something like this with Oracle once using a CONNECT BY clause but I'm not too sure how to do that here.
idx | parent | deleted
-----+--------+---------
3 | 2 | 0
101 | 1 | 0
103 | 1 | 0
104 | 1 | 0
105 | 1 | 0
107 | 1 | 0
108 | 1 | 0
111 | 1 | 0
109 | 1 | 0
113 | 1 | 0
115 | 1 | 0
1 | 0 | 0
2 | 1 | 0
117 | 1 | 0
4 | 1 | 0
118 | 117 | 0
Does this make sense to anyone?
Paul
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2001-01-05 18:42:38 | Re: [SQL] Casting |
Previous Message | rob | 2001-01-05 13:24:34 | Re: Casting |