Select *
from parameter_node
Where name = 'test1111'
AND parent.id = 3
AND parent.parent.id= 2
AND parent.parent.parent.id=1
AND parent.parent.parent.parent.id IS NULL
with recursive tree as (
select *
from parameter_node
where name = 'test1111'
union all
select p.*
from parameter_node p
join tree t on t.parent_id = p.id
)
select *
from tree;
1条答案
按热度按时间4zcjmb1e1#
如果“verify”的意思是,为了简单地获取所有父节点,可以使用递归公共表表达式:
以上是标准的ansi sql
在线示例