。考虑到这是实际加入的第一个答案(而不是在with子查询中),这应该是真正被接受的答案。应重命名该问题或该问题,以避免混淆postgresql是否支持update中的联接。应注意,根据文档(),在from子句中列出目标表将导致目标表自联接。不太自信的是,在

。考虑到这是实际加入的第一个答案(而不是在with子查询中),这应该是真正被接受的答案。应重命名该问题或该问题,以避免混淆postgresql是否支持update中的联接。应注意,根据文档(),在from子句中列出目标表将导致目标表自联接。不太自信的是,在,postgresql,join,sql-update,Postgresql,Join,Sql Update,。考虑到这是实际加入的第一个答案(而不是在with子查询中),这应该是真正被接受的答案。应重命名该问题或该问题,以避免混淆postgresql是否支持update中的联接。应注意,根据文档(),在from子句中列出目标表将导致目标表自联接。不太自信的是,在我看来,这也是一种交叉自连接,可能会产生意外的结果和/或性能影响。 update vehicles_vehicle v join shipments_shipment s on v.shipment_id=s.id set v.pr


。考虑到这是实际加入的第一个答案(而不是在with子查询中),这应该是真正被接受的答案。应重命名该问题或该问题,以避免混淆postgresql是否支持update中的联接。应注意,根据文档(),在from子句中列出目标表将导致目标表自联接。不太自信的是,在我看来,这也是一种交叉自连接,可能会产生意外的结果和/或性能影响。
update vehicles_vehicle v 
    join shipments_shipment s on v.shipment_id=s.id 
set v.price=s.price_per_vehicle;
ERROR:  syntax error at or near "join"
LINE 1: update vehicles_vehicle v join shipments_shipment s on v.shi...
                                  ^
[ 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 ] [, ...] ]
UPDATE vehicles_vehicle AS v 
SET price = s.price_per_vehicle
FROM shipments_shipment AS s
WHERE v.shipment_id = s.id 
UPDATE a
SET price = b_alias.unit_price
FROM      a AS a_alias
LEFT JOIN b AS b_alias ON a_alias.b_fk = b_alias.id
WHERE a_alias.unit_name LIKE 'some_value' 
AND a.id = a_alias.id;
update vehicles_vehicle v
set price=s.price_per_vehicle
from shipments_shipment s
where v.shipment_id=s.id;
-- Doesn't work apparently
update vehicles_vehicle 
set price=s.price_per_vehicle
from vehicles_vehicle v
join shipments_shipment s on v.shipment_id=s.id;
update name3
set mid_name = name.middle_name
from name
where name3.person_id = name.person_id;
with t as (
  -- Any generic query which returns rowid and corresponding calculated values
  select t1.id as rowid, f(t2, t2) as calculatedvalue
  from table1 as t1
  join table2 as t2 on t2.referenceid = t1.id
)
update table1
set value = t.calculatedvalue
from t
where id = t.rowid
with t as (
    select v.id as rowid, s.price_per_vehicle as calculatedvalue
    from vehicles_vehicle v 
    join shipments_shipment s on v.shipment_id = s.id 
)
update vehicles_vehicle
set price = t.calculatedvalue
from t
where id = t.rowid
UPDATE a
SET price = b_alias.unit_price
FROM      a AS a_alias
LEFT JOIN b AS b_alias ON a_alias.b_fk = b_alias.id
WHERE a_alias.unit_name LIKE 'some_value' 
AND a.id = a_alias.id
--the below line is critical for updating ONLY joined rows
AND a.pk_id = a_alias.pk_id;
UPDATE product
SET net_price = price - price * discount
FROM
product_segment
WHERE
product.segment_id = product_segment.id;
update common.tbl_table1 as tab1
set ac_status= 'INACTIVE' --tbl_table1's "ac_status"
from common.tbl_table2 as tab2
where tab1.ref_id= '1111111' 
and tab2.rel_type= 'CUSTOMER';