pg由于对大小写不敏感,如果字段中有大写,需要将该字段加双引号,否则自动转为小写查询
with RECURSIVE cte as
(select a.id,a.name,a."parentId" from system_area a where id=130000
union all
select k.id,k.name,k."parentId" from system_area k inner join cte c on c.id = k."parentId"
)
select string_agg(id||'',',') AS allTitle from cte;