SELECT a.*
FROM tablename a
WHERE NOT EXISTS (SELECT 1 FROM tablename b WHERE b.Fid = a.id)
START WITH Fid = 0 CONNECT BY PRIOR id=a.Fid;
常用的做法:
id in (SELECT a.id
FROM tablename a
WHERE NOT EXISTS (SELECT 1 FROM tablename b WHERE b.Fid = a.id)
START WITH Fid = 0 CONNECT BY PRIOR id=a.Fid)