【发布时间】:2022-01-07 04:40:59
【问题描述】:
所以这是我第一次想对具有多个连接的查询进行更新。
数据库 = Postgres v.10
这是我迄今为止尝试过的:
update table1 t1 set t4.datum = t1.datum
from table1 t1
inner join table3 t3 on t3.id = t1.id
inner join table4 t4 on t4.id = t3.t4_id
where t3.id = 550 and t4.scale is not null and t4.datum is null
错误:SQL 错误 [42712]:错误:表名“t1”指定了多次
下一次尝试:
update table1 t1 set t4.datum = t.datum
from table1 t
inner join table3 t3 on t3.id = t.id
inner join table4 t4 on t4.id = t3.t4_id
where t3.id = 550 and t4.scale is not null and t4.datum is null
错误:SQL 错误 [42703]:错误:关系“table1”的列“t4”不存在 职位:28
最后一次尝试:
update table1 t1 set t4.datum = t.datum
from table1 t
inner join table3 t3 on t3.id = t.id
inner join table4 t4 on t4.id = t3.t4_id
where t1.id = t.id and t3.id = 550 and t4.scale is not null and t4.datum is null
错误:SQL 错误 [42703]:错误:关系“table1”的列“t4”不存在 职位:28
我做错了什么?
【问题讨论】:
标签: postgresql join