gpt4 book ai didi

postgresql - 从 select 语句中调用返回值

转载 作者:行者123 更新时间:2023-11-29 13:06:10 24 4
gpt4 key购买 nike

我需要将多边形插入到 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;

最佳答案

如果你使用的是 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;

关于postgresql - 从 select 语句中调用返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11042112/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com