同一张表中的树形查询

xiaoxiao2021-02-28  60

Oracle数据库中,一张表中存储树形结构数据时的查询.

1.从父节点往下查找

select * from table start with id=? connect by priot id=parent_id

其中start with 与 connect by 为关键字.

2.从当前子节点往上查找

select * from table start with id=? connect by prior parent_id=id查询数据时 id=parent_id --为楼梯向下走 parent_id=id --为楼梯向上走
转载请注明原文地址: https://www.6miu.com/read-2626650.html

最新回复(0)