sql - Oracle Hierarchical Query - Get records in hierarchy wich children are in a list -
i have table parent,child relationship. on table have list of members leafs in first table. have first table filtered members parents of member in second table, or members of second table. hope problem clear, if not please ask.
database oracle 10g.
let's have hierarchy in table th
, in members table tm
there 3 rows 'gc carl', 'pt mike', 'pt mary' (marked green).
to find parents, grandparents etc. (marked yellow) need simple hierarchical query:
select distinct id th connect id = prior pid start id in (select id tm)
if looking parents , need in hierarchical way then:
select distinct id th connect id = prior pid , level <= 2 start id in (select id tm)
(martin eliminated, because not parent member , absent in tm
).
if not wanted should precise query, add sample input data , desired output.
Comments
Post a Comment