Oracle
 sql >> Datenbank >  >> RDS >> Oracle

Rekursive SQL-Abfrage auf selbstreferenzierende Tabelle (Oracle)

Verwendung:

    SELECT t1.id, 
           t1.parent_id, 
           t1.name,
           t2.name AS parent_name,
           t2.id AS parent_id
      FROM tbl t1
 LEFT JOIN tbl t2 ON t2.id = t1.parent_id
START WITH t1.id = 1 
CONNECT BY PRIOR t1.id = t1.parent_id