admin

Oracle对树形结构按级次排序SQL

admin lua 2023-02-26 877浏览 0
1、自顶向下查找
      select t.name, t.id
  from tree t
 start with t.id = ‘top’
CONNECT BY PRIOR t.id = t.parent_id
 order SIBLINGS by t.order_no
2、自底向上查找
select t.name, t.id
  from tree t
 start with t.id = ‘top’
CONNECT BY PRIOR t.parent_id = t.id
 order SIBLINGS by t.order_no

继续浏览有关 数据库技术文章/教程 的文章
发表评论