Postgresql递归查询

来源:互联网 发布:c编程思想pdf 编辑:程序博客网 时间:2024/06/05 20:03

数据表



with RECURSIVE cte as 
 ( 
 select a.* from department a where name='东南片区' 
  union all  
  select k.*  from department k inner join cte c on c.name = k.parent_dep 
 )select * from cte;