zoukankan      html  css  js  c++  java
  • oracle树结构查询

    详细参考:http://blog.csdn.net/crazyxingjc/article/details/7756299

    语法:

    select * from table 
      start with cond1
      connect by cond2
      where cond3;

    典型的查询方式:

    (1)查子节点

    select t.id, t.pid, t.name from t_tree t
      start with t.id = 100 --开始节点
      connect by prior t.id = t.pid; -- id优先,向下查子节点
      -- 或 connect by t.pid = prior t.id

    (2)查父节点

    select t.id, t.pid, t.name from t_tree t
      start with t.id = 100 --开始节点
      connect by prior t.pid = t.id; -- pid优先,向上查父节点
      -- 或 connect by t.id = prior t.pid

    (3)只查本节点,不加prior即可

  • 相关阅读:
    swift
    swift
    swift
    swift
    swift
    swift
    swift
    选择排序
    组合 和 继承
    Android中使用LitePal操控SQLite数据库
  • 原文地址:https://www.cnblogs.com/sleepyy/p/3096877.html
Copyright © 2011-2022 走看看