I'm trying to use the output from two SELECT statements in a PostGIS function.
What is the correct syntax for doing this? I'm getting a syntax error at or near the second SELECT statement.
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 output:
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
Thanks!
Demonstrating one method of using a 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) );
Docs at http://www.postgresql.org/docs/current/static/queries-with.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With