查看: 2145|回复: 0

[Oracle数据库] ORACLE数据库递归查询当前节点的父节点和子节点(tree)

发表于 2018-3-8 08:00:02

ORACLE 数据库递归查询当前数据的所有孩子数据(不包含自己)

  1. SELECT id AS id,
  2. parent_id AS parentId,
  3. parent_id AS parent,
  4. name AS text
  5. FROM mdm_center
  6. START WITH parent_id = #{parentId}
  7. CONNECT BY prior id = parent_id
复制代码

ORACLE数据库查询当前数据的所有父数据(包含自己)

  1. SELECT id AS id,
  2. parent_id AS parentId,
  3. parent_id AS parent,
  4. name AS text
  5. FROM mdm_center
  6. START WITH id = #{centerId}
  7. CONNECT BY prior parent_id = id
复制代码




回复

使用道具 举报