Re: logic/db question

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: logic/db question
Дата
Msg-id b42b73150608021411vb918604wa605b7211ddfa83@mail.gmail.com
обсуждение исходный текст
Ответ на logic/db question  ("bruce" <bedouglas@earthlink.net>)
Список pgsql-general
On 8/2/06, bruce <bedouglas@earthlink.net> wrote:
> hi...
>
> i have a tbl
>  fooTBL
>    name
>    parentID
>    ID
>
> so a name can have might have a parentID, as well as an ID. 'name's are
> associated with other 'name's via the parentID. in other words, if a name's
> parentID == a name's ID, name1 is the parent of name2.
>
>   name  parentID        ID
>   foo            -              1
>   cat           1               2
>   dog   2               3
>
> my question, how can i come up with a sql query that will list all the
> children (and children's children...) of a top level item?
>
> i had done this awhile ago.. but can't recall how i did it..
>

you can try tablefunc contrib module, or recursive pl/pgsql

http://people.planetpostgresql.org/merlin/index.php?/archives/2-Dealing-With-Recursive-Sets-With-PLPGSQL.html

merlin

В списке pgsql-general по дате отправления:

Предыдущее
От: MargaretGillon@chromalloy.com
Дата:
Сообщение: Re: Tape backup, 2 versions, same database name, which is pg_dump
Следующее
От: "Nikolay Samokhvalov"
Дата:
Сообщение: Re: Join Question