pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedHelp with a "recursive" query
2+ messages / 2 participants
[nested] [flat]
* Help with a "recursive" query
@ 2002-06-19 07:30 Jerome Alet <alet@unice.fr>
2002-06-19 08:41 ` Re: Help with a "recursive" query Oleg Bartunov <oleg@sai.msu.su>
0 siblings, 1 reply; 2+ messages in thread
From: alet@unice.fr @ 2002-06-19 07:30 UTC (permalink / raw)
To: pgsql-sql
Hi,
I've got a table like this :
id parent description
01 00 xxxxxx
02 00 xxxxxx
03 01 xxxxxx
04 02 xxxxxx
05 01 xxxxxx
06 05 xxxxxx
07 03 xxxxxx
08 07 xxxxxx
09 00 xxxxxx
10 02 xxxxxx
I want to get all tuples which have id=01 as their parent
or ancestor, i.e. :
03, 05, 06, 07, 08
this to represent a sort of n-tree :
01
/ \
/ \
/ \
03 05
/ \
/ \
/ \
07 06
|
|
|
08
this example is simple because each node has at most one child, but in
my real data there's no such limit.
any idea ?
thanks in advance
Jerome Alet
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Help with a "recursive" query
2002-06-19 07:30 Help with a "recursive" query Jerome Alet <alet@unice.fr>
@ 2002-06-19 08:41 ` Oleg Bartunov <oleg@sai.msu.su>
0 siblings, 0 replies; 2+ messages in thread
From: Oleg Bartunov @ 2002-06-19 08:41 UTC (permalink / raw)
To: Jerome Alet <alet@unice.fr>; +Cc: pgsql-sql
Jerome,
our module 'tree' is ideally suited for your problem.
It could be downloaded from http://www.sai.msu.su/~megera/postgres/gist/
Unfortunately, we have no time to write doc in english. Several people
in mailing list have discussed it. Probably, they could help.
Oleg
On Wed, 19 Jun 2002, Jerome Alet wrote:
> Hi,
>
> I've got a table like this :
>
> id parent description
> 01 00 xxxxxx
> 02 00 xxxxxx
> 03 01 xxxxxx
> 04 02 xxxxxx
> 05 01 xxxxxx
> 06 05 xxxxxx
> 07 03 xxxxxx
> 08 07 xxxxxx
> 09 00 xxxxxx
> 10 02 xxxxxx
>
>
> I want to get all tuples which have id=01 as their parent
> or ancestor, i.e. :
>
> 03, 05, 06, 07, 08
>
> this to represent a sort of n-tree :
>
> 01
> / \
> / \
> / \
> 03 05
> / \
> / \
> / \
> 07 06
> |
> |
> |
> 08
>
> this example is simple because each node has at most one child, but in
> my real data there's no such limit.
>
> any idea ?
>
> thanks in advance
>
> Jerome Alet
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
Regards,
Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2002-06-19 08:41 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-06-19 07:30 Help with a "recursive" query Jerome Alet <alet@unice.fr>
2002-06-19 08:41 ` Oleg Bartunov <oleg@sai.msu.su>
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