Q: Tree traversal with SQL query?

Поиск
Список
Период
Сортировка
От Adrian von Bidder
Тема Q: Tree traversal with SQL query?
Дата
Msg-id 200706151020.33155.avbidder@fortytwo.ch
обсуждение исходный текст
Ответы Re: Q: Tree traversal with SQL query?  (Alban Hertroys <alban@magproductions.nl>)
Список pgsql-general
Hi,

Is there any way to do tree traversal with only one SQL query (no
procedure/function)?

CREATE TABLE foo (
  node INTEGER,
  parent INTEGER REFERENCES foo(node)
);

Ideally the output would be a depth-first tree traversal starting at root
(marked by parent == node, for example.)

Obviously, I can do this with "normal" programming and loops, but it bugged
me a while if its at all possible doing this in one query.

cheers
-- vbi

--
Available for key signing in Zürich and Basel, Switzerland
                    (what's this? Look at http://fortytwo.ch/gpg/intro)

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

Предыдущее
От: "Albe Laurenz"
Дата:
Сообщение: Re: DeadLocks...
Следующее
От: Adrian von Bidder
Дата:
Сообщение: "Constant" fields in a table