FROM 中的子查询必须有别名 POSTGIS
subquery in FROM must have an alias POSTGIS
我正在尝试在 POSTGIS (Postgres) 数据库上使用以下查询。原题:https://gis.stackexchange.com/questions/313252/postgis-sql-query-filter-by-bounding-box
SELECT row_to_json(fc)
FROM (
SELECT 'FeatureCollection' As type,
array_to_json(array_agg(f)) As features
FROM (
SELECT 'Feature' As type,
ST_AsGeoJSON(lg.geom)::json As geometry,
row_to_json((id, name)) As properties
FROM lines As lg
WHERE lg.geom &&
ST_SETSRID(
ST_MakeBox2D(
ST_MakePoint(p_BB_XLong_MIN_3857, p_BB_YLat_MIN_3857),
ST_MakePoint(p_BB_XLong_MAX_3857, p_BB_YLat_MAX_3857)),
3857))
) As f) As fc;
但是,我收到以下错误:
subquery in FROM must have an alias
您似乎没有正确计算 (
和 )
。
在 As f
之前删除 1 )
应该没问题。
我正在尝试在 POSTGIS (Postgres) 数据库上使用以下查询。原题:https://gis.stackexchange.com/questions/313252/postgis-sql-query-filter-by-bounding-box
SELECT row_to_json(fc)
FROM (
SELECT 'FeatureCollection' As type,
array_to_json(array_agg(f)) As features
FROM (
SELECT 'Feature' As type,
ST_AsGeoJSON(lg.geom)::json As geometry,
row_to_json((id, name)) As properties
FROM lines As lg
WHERE lg.geom &&
ST_SETSRID(
ST_MakeBox2D(
ST_MakePoint(p_BB_XLong_MIN_3857, p_BB_YLat_MIN_3857),
ST_MakePoint(p_BB_XLong_MAX_3857, p_BB_YLat_MAX_3857)),
3857))
) As f) As fc;
但是,我收到以下错误:
subquery in FROM must have an alias
您似乎没有正确计算 (
和 )
。
在 As f
之前删除 1 )
应该没问题。