get ALL last level children (leafs) from a node (hierarhical queries Oracle 11G)

前端 未结 2 1494
轻奢々
轻奢々 2021-01-13 19:40

I am trying and searching the way to get ALL last level children (leafs) from a node, in a hierchical query in Oracle 11g database.

I have 2 tables

2条回答
  •  春和景丽
    2021-01-13 20:28

    You can simply use CONNECT_BY_ISLEAF.

    SELECT n.id, n.val
    FROM NODES n 
    LEFT JOIN RELATION r ON (n.id = r.id_child)
    WHERE CONNECT_BY_ISLEAF = 1
    CONNECT BY PRIOR n.id = r.id_father
    START WITH r.id_father IS NULL
    

提交回复
热议问题