3

我正在尝试在 PostGIS 函数中使用两个 SELECT 语句的输出。

这样做的正确语法是什么?在第二个 SELECT 语句处或附近出现语法错误。

SELECT ST_Split(tracks, roads)
FROM
(
    SELECT * FROM (SELECT ST_Buffer(road_geom,50) FROM table1 WHERE a = '' AND b = '') as roads,
    SELECT * FROM (SELECT the_geom FROM table2 WHERE c = '' AND d = '') as tracks

)

错误输出:

 ERROR:  syntax error at or near "SELECT"
 LINE 5:  SELECT * FROM (SELECT the_geom FROM table2...
     ^
********** Error **********
ERROR: syntax error at or near "SELECT"
SQL state: 42601
Character: 178

谢谢!

4

1 回答 1

5

演示一种使用 CTE 的方法:

WITH    roads as (SELECT ST_Buffer(road_geom,50) as road FROM table1 WHERE a = '' AND b = ''),
        tracks as (SELECT the_geom as track FROM table2 WHERE c = '' AND d = '')
SELECT ST_Split( (select track from tracks), (select road from roads) );

http://www.postgresql.org/docs/current/static/queries-with.html上的文档

于 2013-10-25T16:54:18.120 回答