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'));
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'));
omygod