比如:
name age next
a    18   b
b    19   c
c    20   d
d    21   e
e    22   a
那能否跟给定name,取出连续的3条数据呢?要效率的

解决方案 »

  1.   

    create table tb(name varchar(2),age int ,next varchar(2));
    insert into tb select
    'a',    18,   'b' union all select
    'b',    19,   'c' union all select
    'c',    20,   'd' union all select
    'd',    21,   'e'  union all select
    'e',    22,   'a' ;select * from tb;select *
    from tb where name='a'
    union all
    select *
    from tb where name in (select next from tb where name='a')
    union all
    select *
    from tb where name in(select next
                          from tb where name in (select next from tb where name='a'));
      

  2.   

    那我查询10条不就惨了?
    omygod
      

  3.   

    是啊,我也有同问,ORACLE中有start with ... connet by prior 的