select distinct 终点节点   
from table
where 起始节点  in (select 终点节点 from table where 起始节点  =a) or  起始节点  =a

解决方案 »

  1.   

    select 终点节点 from route start with 起始节点='a' connect by prior 终点节点=起始节点;
      

  2.   

    用 connect by.select distinct ends
      from xianlu t
    connect by t.starts = prior t.ends
     start with t.starts = 'a'
     order by ends注释:starts 起点,    ends 终点,
      

  3.   

    但这个方法有个限制,不能形成回路.
    比如说:
    a-b
    b-c
    a-c
    这种情况是可以的
    但下面这种情况会出错
    a-b
    b-c
    c-a
      

  4.   

    guanjm(st.human)
    要针对这个表你答的没错,要是随便加一行 m , n, 300
    就不对了
      

  5.   

    也是对的
    你加上 m,n,300
    按照你的要求 也是a所到达不了的呀.
      

  6.   

    我的就是正确答案啊:
    用 connect by.select distinct ends
      from xianlu t
    connect by t.starts = prior t.ends
     start with t.starts = 'a'
     order by ends注释:starts 起点,    ends 终点,
      

  7.   

    select distinct ends
      from xianlu t
    connect by t.starts = prior t.ends
     start with t.starts = 'a'
     order by ends
    -----------------------------
    我查过了,oracle10g还有connect_by_root 直接查最终节点,强
      

  8.   

    connect by t.starts = prior t.ends
     start with t.starts = 'a'
     order by ends
    这个8i支持吗,很好的东东,没有见过啊
      

  9.   

    xxc1981(asf) 是正确答案,
    不过也可以自己写绨归的实现。