oracle:
select id ,name from base_city start with base_city.id=10002 CONNECT by PRIOR base_city.id=base_city.parentid;
postgreSql:
WITH RECURSIVE r AS (select id ,name,parentid from base_city WHERE id=10002
union ALL
SELECT base_city.id ,base_city.name,base_city.parentid FROM base_city, r WHERE base_city.parentid = r.id
)
SELECT * FROM r ;
with RECURSIVE r as(select * from ry_travel_area where id = 1
union all select ry_travel_area.* from r, ry_travel_area where r.id = ry_travel_area.p_id)
delete from ry_travel_area where exists (select id from r where r.id = ry_travel_area.id)