Oracle 10g PL/SQL Connect By Prior returning Child and Parent on same row -
table1: child parent bob chris 2 chris kate 1 shane lana 3 nala bob 4 table2: b talent 1 'something' 2 'nothing' 3 'something' 4 'nothing' select child table1 inner join table2 on (table1.a = table2.b) table2.talent = 'something' connect prior table1.child = table1.parent
this code returns rows of parents
chris
if "where" clause not included, code return:
bob chris kate chris kate shane lana etc
what want return following in row, not in columns:
bob chris
where chris 1 talent , parent bob, code returns not parent, child originated query parent, in code:
select child table1 inner join table2 on (table1.a = table2.b) table2.talent = 'something' connect prior table1.child = table1.parent
i have child chris talent , previous child bob originated search chris, lets if bob child gala , gala child chris, still want bob , chris in result.
conditions: not have permission create temporary or sort of tables, cannot use loop unless not know how without temporary table
i not know how can return child before "prior" statement , new "child" parent of previous child.
you can use "hr" database test
select last_name "employee", connect_by_root last_name "manager", level-1 "pathlen", sys_connect_by_path(last_name, '/') "path" employees level > 1 , department_id = 110 connect prior employee_id = manager_id; employee manager pathlen path --------------- ------------ ---------- ---------------------------- higgins kochhar 1 /kochhar/higgins gietz kochhar 2 /kochhar/higgins/gietz gietz higgins 1 /higgins/gietz higgins king 2 /king/kochhar/higgins gietz king 3 /king/kochhar/higgins/gietz
Comments
Post a Comment