pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: George Essig <george_essig@yahoo.com>
To: Sergei Levchenko <serg@city.gov.te.ua>
Cc: pgsql-general@postgresql.org
Cc: pgsql-sql@postgresql.org
Subject: Re: connectby
Date: Mon, 27 Oct 2003 18:23:56 -0800 (PST)
Message-ID: <20031028022356.45528.qmail@web80208.mail.yahoo.com> (raw)

> 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



view thread (6+ messages)  latest in thread

Message-ID: <20031028022356.45528.qmail@web80208.mail.yahoo.com>
Permalink:  ../20031028022356.45528.qmail@web80208.mail.yahoo.com/
Also on:    postgresql.org/message-id/20031028022356.45528.qmail@web80208.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: george_essig@yahoo.com, serg@city.gov.te.ua, pgsql-general@postgresql.org
  Subject: Re: connectby
  In-Reply-To: <20031028022356.45528.qmail@web80208.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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