id  父id
1   0
2   1
3   1
4   2
5   3
6   3
7   5
比如:如果id=7
要求查询id=7与
(
select id from 表A
start with id=7
connect by prior 父id=id
)
的组合,比如
那么显示出来是:
id     
7   7
7   5
7   3
7   1这个sql 应该如何写呢

解决方案 »

  1.   

    select 7,id from tab01
    start with id=7
    connect by prior fatid=id;
      

  2.   

    我是想写个视图表A记录集如下:
    id  父id
    1   0(表示无父id)
    2   1
    3   1
    4   2
    5   3
    6   3
    7   5
    这个视图我希望查出的结果:
             7          1
             7          3
             7          5
             7          7
             6          6
             6          3
             6          1
             5          5
             5          3
             5          1
             4          4
             4          2
             4          1
             3          3
             3          1
             2          2
             2          1
             1          1
      

  3.   

    http://community.csdn.net/Expert/TopicView.asp?id=5569114
    http://community.csdn.net/Expert/TopicView.asp?id=5569124
    http://community.csdn.net/Expert/TopicView.asp?id=5569130大家帮个忙,三贴一并给分,谢谢了!!^_^
      

  4.   

    select id ,父id from 表A where id=参数
    union all
    select id ,父id from 表A
    start with id=参数
    connect by prior 父id=id