Postgresql基于join的更新查询
Postgresql updating query based on join
我正在尝试更新我在简单连接上创建的 table。我已经尝试了很多不同的方法,但仍然出现错误。任何帮助都适用
Update well.formation_assignments as v
set
Primary_Formation = well.geo.primary_formation
from well.geo as s
inner join
on well.formation_assignments.api14=well.geo.api14;
错误:“on”处或附近的语法错误
第 6 行:在 well.formation_assignments.api14=well.geo.api14 上;
^
SQL 状态:42601
字符:123
试试这个:
UPDATE well.formation_assignments v
SET Primary_Formation = s.primary_formation
FROM well.geo s
WHERE v.api14 = s.api14;
标准的 Postgresql 更新语法如下:
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ [ AS ] alias ]
SET { column = { expression | DEFAULT } |
( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
[ FROM from_list ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]
我正在尝试更新我在简单连接上创建的 table。我已经尝试了很多不同的方法,但仍然出现错误。任何帮助都适用
Update well.formation_assignments as v
set
Primary_Formation = well.geo.primary_formation
from well.geo as s
inner join
on well.formation_assignments.api14=well.geo.api14;
错误:“on”处或附近的语法错误 第 6 行:在 well.formation_assignments.api14=well.geo.api14 上; ^ SQL 状态:42601 字符:123
试试这个:
UPDATE well.formation_assignments v
SET Primary_Formation = s.primary_formation
FROM well.geo s
WHERE v.api14 = s.api14;
标准的 Postgresql 更新语法如下:
[ WITH [ RECURSIVE ] with_query [, ...] ]
UPDATE [ ONLY ] table [ [ AS ] alias ]
SET { column = { expression | DEFAULT } |
( column [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...]
[ FROM from_list ]
[ WHERE condition | WHERE CURRENT OF cursor_name ]
[ RETURNING * | output_expression [ [ AS ] output_name ] [, ...] ]