Обсуждение: connectby

Поиск
Список
Период
Сортировка

connectby

От
Sergei Levchenko
Дата:
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


Re: connectby

От
George Essig
Дата:
> 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

Re: connectby

От
BenLaKnet
Дата:
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
 

Re: connectby

От
Joe Conway
Дата:
BenLaKnet wrote:
> I use postgresql 7.2.3
> How can I use connectby ??
>
> Must I install files ? or packages ? or it is recommanded to upgrade
> dataserver ?

You need to upgrade. Either install 7.3.4 or wait a few weeks and
install 7.4 when it is released.

Joe




Re: connectby

От
George Essig
Дата:
> I use postgresql 7.2.3
> How can I use connectby ??
>
> Must I install files ? or packages ? or it is recommanded to upgrade dataserver ?

For recent versions of PostgreSQL, go into the contrib/tablefunc directory and see the readme file
for how to install.  I downloaded PostgreSQL 7.2.3 and there was no contrib/tablefunc directory.
You'll have to upgrade.

George Essig

Re: connectby

От
Benoît BOURNON
Дата:
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