Forum OpenACS Q&A: Extracting all 'node_id' in one branche

Collapse
Posted by xx xx on
I'm looking for code that will return all node_id’s from the site_nodes table that belong to one branche. For example all node_id’s that belong to a certain class or community (subdirectories in the site-map).

I suppose I should use tree_sortkey, but I didn’t find existing procs, so I could use some advice here.

Collapse
Posted by Dan Wickstrom on
Try something like the following:

select n1.* from site_nodes n1,
       (select tree_sortkey from site_nodes where node_id = :branch_root_node) n2 
where n1.tree_sortkey between n2.tree_sortkey and tree_right(n2.tree_sortkey);