2
我有一個與(非空間)表格具有一對多關係的醫院(點)的空間表格,價格表(cirurgy,urgency等)在Postgis中如何從空間表格和相關(非空間)表格之間的一對多關係構建Geojson
hospital(id,name,geom); 價(id,name,valence)
「name」是常用字段。
如何在PostgreSQL/Postgis中構建一個有效的Geojson,其中每個醫院(點)可以有一個或多個價位?
我已經試過這個查詢的一些變體,但總是給出「用作表達式的子查詢返回的多個行」的錯誤。
SELECT row_to_json(fc) FROM
(
SELECT 'FeatureCollection' As type, array_to_json(array_agg(f)) As features from
(
SELECT 'Feature' As type, ST_AsGeoJSON(lg.geom)::json As geometry, row_to_json
((select l from (select
v.*
FROM valence v
inner join hospital lg on lg."name" = v."name") As l
)) As properties
from hospital as lg)
As f
) As fc;
非常感謝!
很多,很多的感謝是有效的,thibautg! –