如何突破第三次嵌套的查询?
SELECT CHILD_ID
FROM COLLECTION_ITEMS
START WITH PARENT_ID = 16917
CONNECT BY PRIOR CHILD_ID = PARENT_ID
我有这样的查询,如果嵌套增加到三个以上我必须结束查询。
答案 0 :(得分:3)
您可以使用LEVEL伪列。
SELECT
CHILD_ID
FROM
COLLECTION_ITEMS
WHERE
LEVEL <= 3
START WITH PARENT_ID = 16917
CONNECT BY PRIOR CHILD_ID = PARENT_ID