X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CB697D1B514; Tue, 28 Oct 2003 14:30:28 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 97080-06; Tue, 28 Oct 2003 10:30:01 -0400 (AST) Received: from neptune.adelis.net (neptune.adelis.net [195.115.171.102]) by svr1.postgresql.org (Postfix) with ESMTP id 599D9D1B4F4; Tue, 28 Oct 2003 10:29:54 -0400 (AST) Received: from adelis.com (ben.adelis.net [195.115.171.16]) by neptune.adelis.net (Postfix) with ESMTP id 997367918B; Tue, 28 Oct 2003 15:20:23 +0100 (CET) Message-ID: <3F9E7D54.9040805@adelis.com> Date: Tue, 28 Oct 2003 15:29:40 +0100 From: =?ISO-8859-1?Q?Beno=EEt_BOURNON?= User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031014 Thunderbird/0.3 X-Accept-Language: en-us, en MIME-Version: 1.0 Cc: pgsql-general@postgresql.org, pgsql-sql@postgresql.org Subject: Re: [SQL] connectby References: <20031028022356.45528.qmail@web80208.mail.yahoo.com> In-Reply-To: <20031028022356.45528.qmail@web80208.mail.yahoo.com> Content-Type: multipart/alternative; boundary="------------060607040106010703070302" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1545 X-Sequence-Number: 51617 This is a multi-part message in MIME format. --------------060607040106010703070302 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit I use postgresql 7.2.3 How can I use connectby ?? Must I install files ? or packages ? or it is recommanded to upgrade dataserver ? George Essig wrote: >>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 > >---------------------------(end of broadcast)--------------------------- >TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org > > > --------------060607040106010703070302 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit I use postgresql 7.2.3
How can I use connectby ??

Must I install files ? or packages ? or it is recommanded to upgrade dataserver ?


George Essig wrote:
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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

  
--------------060607040106010703070302--