答案 0 :(得分:0)
从所需的行开始并上升到根目录:
SELECT RiskID,
FROM PROJECT_RISKS
WHERE CONNECT_BY_ISLEAF = 1
START WITH
RiskID = 25
CONNECT BY
PRIOR Link2 = Link1
AND PRIOR ProjectID = ProjectID;
从根开始并下降到所需的行:
SELECT CONNECT_BY_ROOT( RiskID ) AS RiskID
FROM Project_Risks
WHERE RiskID = 25
START WITH
link2 IS NULL
CONNECT BY
PRIOR Link1 = Link2
AND PRIOR ProjectID = ProjectID;
两者都会给出相同的答案。