Re: connectby

From: George Essig <george_essig(at)yahoo(dot)com>
To: Sergei Levchenko <serg(at)city(dot)gov(dot)te(dot)ua>
Cc: pgsql-general(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: Re: connectby
Date: 2003-10-28 02:23:56
Message-ID: 20031028022356.45528.qmail@web80208.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

> 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Joshua D. Drake 2003-10-28 03:31:42 Re: index question
Previous Message Jan Wieck 2003-10-28 01:59:19 Re: index question

Browse pgsql-sql by date

  From Date Subject
Next Message Senthil Kumar S 2003-10-28 08:54:43 Re: Error message during compressed backup
Previous Message Alexander Vlasenko 2003-10-27 19:54:05 Re: extend INSERT by 'INSERT INTO table FETCH ... FROM cursor' syntax