select * from tableName
start with parent=0
connect by prior child=parent

解决方案 »

  1.   

    The following hierarchical query uses the CONNECT BY clause to define the relationship between employees and managers:SELECT employee_id, last_name, manager_id
    FROM employees
    CONNECT BY PRIOR employee_id = manager_id;EMPLOYEE_ID LAST_NAME MANAGER_ID
    ----------- ------------------------- ----------
    101 Kochhar 100
    108 Greenberg 101
    109 Faviet 108
    110 Chen 108
    111 Sciarra 108
    112 Urman 108
    113 Popp 108