1

我需要将多边形插入到 postgresql 表“polygontable”中,然后返回其 (the_geom) 值以进行进一步查询。我想在“polygontable”中获取最近插入的实例。如何在 SELECT 语句中调用返回的“polygongeom”?

INSERT INTO polygontable (the_geom) 
VALUES (ST_SetSRID((ST_MakeValid(ST_GeomFromGeoJSON('"+JSON.stringify(payload)+"'))),4326)) returning the_geom as polygon_geom;  

SELECT st_intersects(polygon_geom, other_table.the_geom) 
from polygon_geom, other_table;
4

1 回答 1

2

如果您使用的是 9.1,则可以执行以下操作:

with inserted as 
(
  insert into ... 
  returning the_geom as new_geom
)
SELECT st_intersects(inserted.new_geom, other_table.the_geom) 
from inserted, other_table;
于 2012-06-14T22:30:39.570 回答