数据库
首页 > 数据库> > ORACLE 父子关系查询

ORACLE 父子关系查询

作者:互联网

  1. 根据父ID查询所有的子数据(向下递归)
    SELECT * FROM TEST START WITH PARENT_ID = '0' CONNECT BY PRIOR ID = PARENT_ID;

  2. 根1据ID查询所有的父级(像上递归)
    SELECT * FROM TEST START WITH ID = '123' CONNECT BY ID = PRIOR PAERENT_ID;

标签:PARENT,PRIOR,查询,父子关系,START,TEST,ORACLE,ID
来源: https://www.cnblogs.com/yolo15/p/15043741.html