connect by 是结构化查询中用到的,其基本语法是:
select ... from tablename start by cond1
connect by cond2
where cond3;
有一张表t 字段: parent child
两个字段的关系是父子关系
写一个sql语句,查询出指定父下面的所有的子
比如
a b
a c
a e
b b1
b b2
c c1
e e1
e e3
d d1
指定parent=a,选出
a b
a c
a e
b b1
b b2
c c1
e e1
e e3
SQL语句:
select parent,child from test start with parent='a'
connect by prior child=parent
select ... from tablename start by cond1
connect by cond2
where cond3;
有一张表t 字段: parent child
两个字段的关系是父子关系
写一个sql语句,查询出指定父下面的所有的子
比如
a b
a c
a e
b b1
b b2
c c1
e e1
e e3
d d1
指定parent=a,选出
a b
a c
a e
b b1
b b2
c c1
e e1
e e3
SQL语句:
select parent,child from test start with parent='a'
connect by prior child=parent