• oracle 递归查询,向上和向下遍历


    --查询全部资源信息 
    select * from urm_class_info 
    --向上遍历树,找到路径直到根节点,指定的是parentid 
    select distinct classid,parentid,name 
    from urm_class_info 
    start with parentid = 'cmdb0000000000000017' 
    connect by prior parentid = classid 
    --向上遍历树,找到路径直到根节点,指定的是classid,和下面的主要区别就是parentid和classid的位置 
    select classid,parentid,name 
    from urm_class_info 
    start with classid = 'cmdb0000000000000401' 
    connect by prior parentid = classid 
    --向下遍历整棵树,可以指定classid,来遍历指定节点的树 
    select classid,parentid,name 
    from urm_class_info 
    start with classid = 'cmdb0000000000000017' 
    connect by prior classid = parentid 
    --向下遍历整棵树,可以指定parentid,来遍历指定parentid节点的树,不包含parentid 
    select classid,parentid,name 
    from urm_class_info 
    start with parentid = 'cmdb0000000000000017' 
    connect by prior classid = parentid 
  • 相关阅读:
    树上莫队学习笔记
    点分治学习笔记
    7.11总结
    线段树合并学习笔记
    7.10总结
    bzoj1201: [HNOI2005]数三角形----递推+bitset
    bitset(01串)优化
    Tarjan系列1
    bsgs(Baby Steps Giant Steps)算法
    [SD2015]序列统计——solution
  • 原文地址:https://www.cnblogs.com/myjoan/p/6382265.html
Copyright © 2020-2023  润新知