ORACLE数据库可以这样写
SELECT 起始,到站,LEVEL
FROM 表名
START WITH 起始='START'
CONNECT BY 起始=PRIOR 到站
或者
with temp(processno,fromnodeno,tonodeno) as (
select processno,fromnodeno,tonodeno from 表名 where processno=' ' AND fromnodeno='START'
union all
select c.processno,c.fromnodeno,c.tonodeno from 表名 c,temp t where c.fromnodeno=t.tonodeno
)
SELECT * from temp