How does everyone handle an N level parent-child type relationship
within the same table?
Say you have the following table setup for Categories
categoryid
category
parentid
You could have any level of categories each with the parent pointing up
the path. The problem I'm interested
Additional parent_path field will help you to retrieve all the
branch starting at a given tree item by a single SELECT query:
SELECT * FROM Categories
WHERE parent_path LIKE '#start_item_path##path_delimiter#%'
If you want to avoid having problems with keeping parent_path field in
actual state
Sergey Croitor wrote:
Additional parent_path field will help you to retrieve all the
branch starting at a given tree item by a single SELECT query:
SELECT * FROM Categories
WHERE parent_path LIKE '#start_item_path##path_delimiter#%'
If you want to efficiently query subsets of the entire
Academic, really, with Oracle 9i. (Which is what we're using at the day job.)
If 7 is the categoryid for Hockey:
select categoryid, category, level
from catalog
start with categoryid=7
connect by parentid = prior categoryid
level is a pseudo-column indicates the level of the tree, starting with
4 matches
Mail list logo