table: Table 
A   B    字段名 
------- 数据 
aa  bb   
ff  dd 
hh  ff 
gg  hh 
ii  gg 
oo  tt 
。 
==========  希望得到如下的查询结果,注意: A字段为ii的B字段,和另外一个记录的A字段相等。其他查出的记录,都是一样的道理。这一组查询,是以A=ii,为前提条件的。 ff  dd 
hh  ff 
gg  hh 
ii  gg 

解决方案 »

  1.   

    select * from table
    start with a='ii'
    connect by prior b=a
    order by level desc
      

  2.   

    start with 和connect by  是不是写反了??
      

  3.   

    select a.a,a.b from table a, table b
    where a.a = b.b;
    利用表的别名,看作2个表
      

  4.   

    start with ... connect by 正解
      

  5.   

    select *
    from a 
    start with a.b='dd'
    connect by prior a.a=a.b
    --结果:
    ff dd
    hh ff
    gg hh
    ii gg