oracle的递归能全部显示上下级关系吗
2个回答
展开全部
可以的
--层次查询,自底到顶
select t.employee_id,t.last_name,t.job_id,t.manager_id,level from employees t
start with t.employee_id=101
connect by prior t.manager_id=t.employee_id;
select t.empno,t.ename,t.job,t.mgr,level from emp t
start with t.empno=7788
connect by prior t.mgr=t.empno;
--层次查询,自顶到底
select t.employee_id,t.last_name,t.job_id,t.manager_id,level from employees t
start with t.employee_id=101
connect by prior t.employee_id=t.manager_id;
select t.empno,t.ename,t.job,t.mgr,level from emp t
start with t.empno=7788
connect by prior t.empno=t.mgr;
--层次查询,自底到顶
select t.employee_id,t.last_name,t.job_id,t.manager_id,level from employees t
start with t.employee_id=101
connect by prior t.manager_id=t.employee_id;
select t.empno,t.ename,t.job,t.mgr,level from emp t
start with t.empno=7788
connect by prior t.mgr=t.empno;
--层次查询,自顶到底
select t.employee_id,t.last_name,t.job_id,t.manager_id,level from employees t
start with t.employee_id=101
connect by prior t.employee_id=t.manager_id;
select t.empno,t.ename,t.job,t.mgr,level from emp t
start with t.empno=7788
connect by prior t.empno=t.mgr;
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询