任何帮助表示赞赏,现在一周,我被困 -
如果可以,非常感谢。我添加了问题的图像,但它已经消失了
WITH SITESmin as (
SELECT public.acc.Location_Easting_OSGR, public.acc.Location_Northing_OSGR
FROM acc Sites ,
ORDER BY ( acc.Location_Easting_OSGR - Sites.SITE_ETG ) * ( acc.Location_Easting_OSGR - Sites.SITE_ETG ) + (acc.Location_Northing_OSGR - "public"."Sites"."SITE_ETG" ) * ( acc.Location_Northing_OSGR - "public"."Sites"."SITE_NTG" )
LIMIT 1
)
UPDATE ACC
SET acc.Location_Easting_OSGR = SITESmin.acc.Location_Easting_OSGR,
acc.Location_Northing_OSGR = SITESmin.acc.Location_Northing_OSGR
FROM SITESmin;
这是错误:
Error : ERROR: syntax error at or near "ORDER"
LINE 4: ORDER BY ( acc.Location_Easting_OSGR - Sites.SITE_ETG )...
^克拉出现在第4行:冒号
之后答案 0 :(得分:1)
第二次看我注意到这个查询有几个问题。如果你使用别名然后坚持这个别名,你有很多错误地定义了字段,或者你发布的查询有一些缺失的部分,并且在你的例子中不存在。和更新部分看起来像缺少条件.... 例如
SELECT public.acc.Location_Easting_OSGR, public.acc.Location_Northing_OSGR
然而你定义了别名"网站",顺便说一下,#34;" as"语法,应该是
FROM acc as Sites
WITH SITESmin as (
SELECT Sites.Location_Easting_OSGR, Sites.Location_Northing_OSGR
FROM acc as Sites --, <--- this coma was is causing that error, it does not belong there or some code is missing
ORDER BY (Sites.Location_Easting_OSGR - Sites.SITE_ETG ) * ( Sites.Location_Easting_OSGR - Sites.SITE_ETG ) + (Sites.Location_Northing_OSGR - Sites.SITE_ETG ) * ( Sites.Location_Northing_OSGR - Sites.SITE_NTG )
LIMIT 1
)
UPDATE ACC
SET acc.Location_Easting_OSGR = SITESmin.Location_Easting_OSGR,
acc.Location_Northing_OSGR = SITESmin.Location_Northing_OSGR
FROM SITESmin
--- missing where condition?
;