表如下
preant    child
1 101
1 102
1 103
101 10101
101 10102
102 10201
103 10301
10101 1010101查询preant为1的所有child
1    101
1    102
1    103
1    10101
1    10102
1    10201
1    1010101
1    10301
1    1
怎么用connet by实现?

解决方案 »

  1.   

    select * from table
    start with preant='1'
    connect by prior child=preant
      

  2.   

    这样查询只能出来
          parent      child
    1 101
    1 102
    1 103
      

  3.   

    才注意你的表结构,没有child的值,那你怎么确定preant为1的所有child的?
    表如下
    preant    child
    1101
    1102
    1103
    10110101
    10110102
    10210201
    10310301
    101011010101
      

  4.   

    拿preant1为例
    1的child有101,102,103
    101的child有10101,10102
    10101的child有1010101关系就出来了
    1的下级包括
    101,102,103,10101,10102,1010101
      

  5.   

    加入ORACLE的群吧;群号是:19312711