我知道树枝为A,树根为B,用什么方式查询出树枝A到树根B的所有记录,要求结果如下:
parent childA aaaa bbbb B
parent childA aaaa bbbb B
解决方案 »
- 00604: 递归 SQL 级别 1 出现错误
- 创建好的存储过程在
- oralce在存储过程中解析xml字符串
- 我要监控数据表的访问量,怎么操作啊?
- 在线等待高手相助: 启动时提示出错:ORA-00064: object is too large to allocate on this O/S(1,4800000)
- 问个简单的问题、关于查找的
- 求有点难度的SQL写法
- 删除表中重复记录,不懂执行过程。哪位高手给解释以下执行过程,感谢!
- 如何根据oracle数据库的数据内容 查找到所属的表格
- 查找连续号中缺失的号码
- oracle 怎么查询唯一索引
- 这条语句有什么办法优化一下?在库里有什么要注意的地方?
start with parent='A'
connect by priod child=parent
INSERT into tb select 'A','aa' from dual;
INSERT into tb select 'aa','bb' from dual;
INSERT into tb select 'bb','B' from dual; select * from tb
start with parent='A'
connect by prior child=parent
from TAB1
start with parent='A'
connect by parent =prior child
and prior child<>'B'
--倒过来就可以了,从末节点到子节点
select *
from TAB1
start with CHILDS='B'
connect by childs=prior parents
--再查A以下的子节点
create table tb (parent varchar2(10),child varchar2(10));
INSERT into tb select 'A','aa' from dual;
INSERT into tb select 'aa','bb' from dual;
INSERT into tb select 'bb','B' from dual;select * from
(
select a.* from tb a
start with child='B'
connect by prior parent=child
)
start with parent ='A'
connect by prior child=parent