我希望我传递的节点级别的所有节点都以子句开头
i want all nodes of level which i node i am passing in start with clause
假设以下是层次结构:
我超过了 5,所以我排除了 5,4,2,1 那么我该怎么做。
提前致谢。
如果您想要 5
的所有祖先和兄弟姐妹,请在 start with
子句中使用父 ID:
/* sample data
with t(id, pid) as (
select 1, null from dual union all
select 2, 1 from dual union all
select 3, 1 from dual union all
select 4, 2 from dual union all
select 5, 2 from dual union all
select 6, 3 from dual ) */
select distinct id
from t connect by prior pid = id
start with pid = (select pid from t where id = 5)
假设以下是层次结构:
我超过了 5,所以我排除了 5,4,2,1 那么我该怎么做。 提前致谢。
如果您想要 5
的所有祖先和兄弟姐妹,请在 start with
子句中使用父 ID:
/* sample data
with t(id, pid) as (
select 1, null from dual union all
select 2, 1 from dual union all
select 3, 1 from dual union all
select 4, 2 from dual union all
select 5, 2 from dual union all
select 6, 3 from dual ) */
select distinct id
from t connect by prior pid = id
start with pid = (select pid from t where id = 5)