大神们!求救!oracle树形表查询,如图该怎么做??

菜鸟的鸟 2019-09-30 10:21:54
...全文
87 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
菜鸟的鸟 2019-10-07
  • 打赏
  • 举报
回复
select connect_by_root(t1.id), id from tab1 t1 where t1.pid is not null start with t1.pid in(select id from work) connect by prior t1.id = t1.pid 提示不能在远程数据库使用start with子查询,怎么办
AT152S 2019-09-30
  • 打赏
  • 举报
回复
with作用是什么?
nayi_224 2019-09-30
  • 打赏
  • 举报
回复
with tab1 as (
select 1 id, null pid from dual union all
select 2 id, 1 pid from dual union all
select 3 id, 1 pid from dual union all
select 4 id, 2 pid from dual union all
select 5 id, 2 pid from dual union all
select 6 id, 3 pid from dual union all
select 7 id, 3 pid from dual 
)
select connect_by_root(t1.id),
       id
  from tab1 t1
 where t1.pid is not null
 start with t1.pid is null
connect by prior t1.id = t1.pid

17,086

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧