【发布时间】:2018-12-27 20:49:26
【问题描述】:
在 MySQL 中可以这样做:
update
table_a A
inner join
table_b B
on
A.field_five = B.field_five
inner join
table_c C
on
B.field_one = C.field_one and A.field_two = C.field_two
set A.field_three = C.field_four
我曾尝试在 PostgreSQL 中像这样构造相同的查询:
update table_a A
set A.field_three = C.field_four
from table_b B
inner join table_c C
on
B.agency_id = C.agency_id and A.field_two = C.field_two
where
A.field_five = B.field_five
我收到以下错误:
错误:对表“a”的 FROM 子句条目的引用无效
我使用的是 PostgreSQL 11。在 postgres 中执行此查询的正确方法是什么?
【问题讨论】: