我正在尝试使用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
谢谢!
答案 0 :(得分:4)
演示一种使用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
的文档