[英]Compound SELECT query postgreSQL / postGIS
Probaby a simple syntax issue but I have this postGIS query I'd like to run on a single table: 可能有一个简单的语法问题,但我有一个postGIS查询,希望在单个表上运行:
SELECT
ST_Overlaps(g1.geom,g2.geom) AS asr_01
FROM
ch03.my_polygons g1, ch03.my_polygons g2
WHERE
g1.agent_type = 0 AND g2.agent_type != 0 AND g1.sim_time = 0.0
which works as expected, but I'd like to also select an adjacent column such as this 它可以按预期工作,但我也想选择一个相邻的列,例如
SELECT
agent_id
FROM
ch03.my_polygons
WHERE
agent_type != 0
which also works fine but how do I combine these? 哪个也可以正常工作,但如何将它们结合起来? Tried this... 试过这个...
SELECT
agent_id,
ST_Overlaps(g1.geom,g2.geom) AS asr_01
FROM
ch03.my_polygons,
ch03.my_polygons g1, ch03.my_polygons g2
WHERE
agent_type != 0,
g1.agent_type = 0 AND g2.agent_type != 0 AND g1.sim_time = 0.0
Possible? 可能? Another way to get around this? 解决这个问题的另一种方法? Thanks 谢谢
OK I figured it out with combining the use of the variables... 好的,我通过结合使用变量来解决了...
SELECT
g2.agent_id,
ST_Overlaps(g1.geom,g2.geom) AS asr_01
FROM
ch03.my_polygons g1, ch03.my_polygons g2
WHERE
g1.agent_type = 0 AND g2.agent_type != 0 AND g1.sim_time = 0.0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.