实际就是个Postgresql的递归运算
with RECURSIVE cte as
(
select unit_parentid from gpm_unit where id=69 //循环体(69是已知的最初单位id)
union all
select gpm_unit.unit_parentid fromgpm_unitinner joincte as con c.unit_parentid = gpm_unit.id//循环条件
)
select unit_parentid from cte;
红色字体是 这段语句的骨架,其余的都是要往上添加的肉