Search Postgresql Archives

Q: Tree traversal with SQL query?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux