CREATE TABLE rotated_bus AS SELECT AO_id,
RotateCoords(ST_Centroid(Geometry) FROM Substation, 45.00) AS Geometry FROM Busbar;
我试图通过在RotateCoords函数内传递多边形几何体(Substation)的质心来旋转线几何体(Busbar)。运行上面的查询后,我收到错误“接近FROM语法错误”。我的查询出了什么问题?
答案 0 :(得分:1)
你可以加入两个表:
CREATE TABLE rotated_bus AS
SELECT Busbar.AO_id,
RotateCoords(ST_Centroid(Substation.Geometry), 45) AS Geometry
FROM Busbar
JOIN Substation ON Busbar.AO_id = Substation.Substn_ID
或者,使用correlated subquery(子查询必须是一对额外括号内的完整查询):
CREATE TABLE rotated_bus AS
SELECT AO_id,
(SELECT RotateCoords(ST_Centroid(Geometry), 45)
FROM Substation
WHERE Substn_ID = Busbar.AO_id
) AS Geometry
FROM Busbar