oracle 10g:connect by

    技术2022-05-12  2

    1.向上循环遍历

    select c.*,level from dms_catalog  c start with c.dms_ch_number='7' connect by prior   c.dms_ch_parentid=c.dms_ch_numberand c.DMS_CH_NAME is not null;

     

     

    2。向下循环遍历

    selectc.*,level fromdms_catalog  cstart withc.dms_ch_number='7'connect by prior   c.dms_ch_number=c.dms_ch_parentid

     

     

    说明:

    表的自包含 树形结构

    表结构中 字段 DMS_CH_PARENTID是外键 关联表主键DMS_CH_NUMBER


    最新回复(0)