Possible Duplicate:
Traversing tree-like data in a relational database using SQL
Whats the best way to traverse a tree in sybase?
Basically, what I want is to gather all the decedents of a certain node. (aka the decedents of the root node is every node in the tree)
I've thought of two things I can do.
- Use recursion on the java end and query multiple times. (obviously less than optimal)
- Transform the naturally recursive problem into an iterative problem and use a while loop and one or two temp tables. This wouldn't actually be that bad.
Is there a better way?