with RECURSIVE tree as //tree作为第一级的变量 id=‘913011‘然后递归 ( select * FROM menu_admin WHERE id=‘913011‘ union all SELECT d.* FROM menu_admin d,tree t WHERE d.parentid=t.id ) SELECT * FROM tree //最后输出的字段
非pg数据库
with RECURSIVE tree as
(
select * FROM menu_admin WHERE id=‘913011‘
union all
SELECT d.* FROM menu_admin d,tree t WHERE d.parentid=t.id
)
SELECT * FROM tree