Re: connectby - Mailing list pgsql-general

From George Essig
Subject Re: connectby
Date
Msg-id 20031028022356.45528.qmail@web80208.mail.yahoo.com
Whole thread Raw
In response to connectby  (Sergei Levchenko <serg@city.gov.te.ua>)
Responses Re: [SQL] connectby  (BenLaKnet <benlaknet@icqmail.com>)
Re: [SQL] connectby  (Benoît BOURNON <benoit.bournon@adelis.com>)
List pgsql-general
> hi
>
> I have menu table:
>   id          | integer | not null default
> nextval('public.menu_id_seq'::text)
>   parent_id   | integer |
>   description | text    |
>
> I do select:
> test=> SELECT * FROM connectby('menu','id','parent_id','2',0,'~') t(id
> integer, parent_id integer, level int, branch text);
>   id | parent_id | level |   branch
> ----+-----------+-------+-------------
>    2 |           |     0 | 2
>    4 |         2 |     1 | 2~4
>    7 |         4 |     2 | 2~4~7
>   10 |         7 |     3 | 2~4~7~10
>   16 |        10 |     4 | 2~4~7~10~16
>    9 |         4 |     2 | 2~4~9
>
> How am I able to select description file from menu table, not only id,
> parent_id, level, branch fields?
>
> --
> WBR, sector119

Try a join with the original table:

SELECT t.*, description FROM connectby('menu','id','parent_id','2',0,'~')
AS t(id integer, parent_id integer, level int, branch text), menu
WHERE t.id = menu.id

George Essig

pgsql-general by date:

Previous
From: Jan Wieck
Date:
Subject: Re: index question
Next
From: "Joshua D. Drake"
Date:
Subject: Re: index question