zoukankan      html  css  js  c++  java
  • oracle中单表树形数据的展示

    在oracle中的单表树形数据,我们可以从上往下展示树形结构,也可以从下往上地展示树形结构。

    connect by prior t.parent_dept_guid=t.dept_guid:可以理解为本条记录的父ID字段是下一条记录的ID字段,即由下往上结构;

    connect by prior a.dept_guid=a.parent_dept_guid:可以理解为本条记录的ID字段是下一条记录的父ID字段,即由上往下结构;

    select a.dept_guid,a.parent_dept_guid,(lpad(' ',to_number(level-1)*2))||dept_name dept_name,a.sub_level,level tree_Level from
    (
      select t.dept_guid,t.parent_dept_guid,t.dept_name,level sub_level from tb_org_dept t
      start with t.dept_guid='321468cb-04cc-4c38-9b40-a4ca7a7d701e' connect by prior t.parent_dept_guid=t.dept_guid
    ) a start with a.parent_dept_guid is null connect by prior a.dept_guid=a.parent_dept_guid;

  • 相关阅读:
    LOJ
    LOJ
    LOJ
    一种树形背包的时间复杂度证明
    [机器学习]第四、五周记录
    [机器学习]第三周记录
    [家里训练20_02_16]C
    [机器学习]第二周记录
    wireshark无响应的问题
    [机器学习]第一周记录
  • 原文地址:https://www.cnblogs.com/junior/p/2014702.html
Copyright © 2011-2022 走看看