oracle递归查询
select id, parentId, 列名1, 列名2 from 表名 START WITH t1.id= ? CONNECT BY PRIOR t1.ID = t1.PARENTID
postgresql递归查询
with recursive 自定义表名 as (
select * from 表名 t1 where t1.id = ?
union all select t2.* from 自定义表名 t1 join 表名 t2 on t1.id = t2.parentid
) select id,areaname from 自定义表名;
************备注:
union、union all 将多表并将数据结果放入同一张表。
union: 合并并覆盖相同数据;
union all: 合并但不覆盖相同数据