Tuesday, October 12, 2010

Oracle - Search nodes of tree structure using connect by

Finding --Bottom to top relation
select entityunitid, entityname
from table name
connect by prior parentunitid = entityunitid
start with entityunitid = bottom id

--Top to Bottom relation
select entityunitid, entityname
from table name
connect by prior entityunitid = parentunitid
start with entityunitid = top id

No comments: