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).

enter image description here

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) 

sqlfiddle demo

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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -