I have a table that defines the child and parent relationships between nodes:
CREATE TABLE node ( ' pseudo code alert
id INTEGER PRIMARY KEY,
parentID INTEGER, ' should be a valid id.
)
If it parentIDalways points to a valid existing node, then this will naturally determine the tree structure.
If parentID- NULL, then we can assume that node is the root of the node.
How would I:
- Find all the nodes that are the decompressions of this node?
- Find all nodes under a given node to a certain depth?
I would like to make each of them as one SQL (I expect it to be necessarily recursive) or two mutually recursive queries.
I do this in the ODBC context, so I cannot rely on any vendor-specific functions.
Edit
.