Oracle递归查询(树型查询)

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 = '子级'; 

 深入(转):oracle 递归查询 CONNECT BY、START WITH、CONNECT_BY_ROOT、CONNECT_BY_ISLEAF、SYS_CONNECT_BY_PATH:https://blog.csdn.net/feier7501/article/details/21815691

posted @ 2018-01-03 17:34  膜拜曾文正  阅读(237)  评论(0编辑  收藏  举报