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

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

  

你可能感兴趣的:(Oracle对树形结构按级次排序SQL)