prior放的左右位置决定了检索是自底向上还是自顶向下. 左边是自上而下(找子节点),右边是自下而上(找父节点)
SELECT T.AREA_CODE, T.AREA_NAME, T.AREA_LEVEL FROM TBL_SYS_AREA_CODE T CONNECT BY PRIOR T.AREA_CODE = T.PARENT_AREA_CODE START WITH T.PARENT_AREA_CODE = ‘父级‘;
SELECT T.AREA_CODE, T.AREA_NAME, T.AREA_LEVEL FROM TBL_SYS_AREA_CODE T CONNECT BY T.AREA_CODE = PRIOR T.PARENT_AREA_CODE START WITH T.Area_Name = ‘子级‘;
原文地址:https://www.cnblogs.com/ViokingJava/p/8184858.html
时间: 2024-10-12 21:54:02