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 579D5D1B53A; Tue, 28 Oct 2003 14:33:55 +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 93335-10; Tue, 28 Oct 2003 10:33:26 -0400 (AST) Received: from neptune.adelis.net (neptune.adelis.net [195.115.171.102]) by svr1.postgresql.org (Postfix) with ESMTP id 1AA88D1B503; Tue, 28 Oct 2003 10:33:17 -0400 (AST) Received: from icqmail.com (ben.adelis.net [195.115.171.16]) by neptune.adelis.net (Postfix) with ESMTP id C2E9B7918B; Tue, 28 Oct 2003 15:24:06 +0100 (CET) Message-ID: <3F9E7E33.5060504@icqmail.com> Date: Tue, 28 Oct 2003 15:33:23 +0100 From: BenLaKnet 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="------------050505040505030303090201" X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/1533 X-Sequence-Number: 51605 This is a multi-part message in MIME format. --------------050505040505030303090201 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 > > > --------------050505040505030303090201 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

  
--------------050505040505030303090201--