sql >> Databasteknik >  >> RDS >> PostgreSQL

Hur gör man en uppdatering + går med i PostgreSQL?

UPDATE-syntaxen är:

[ 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 ] [, ...] ]

I ditt fall tror jag att du vill ha detta:

UPDATE vehicles_vehicle AS v 
SET price = s.price_per_vehicle
FROM shipments_shipment AS s
WHERE v.shipment_id = s.id 


  1. Massuppdatering i C#

  2. Lägga till flera kolumner EFTER en specifik kolumn i MySQL

  3. skillnad mellan localhost och postgres för host i docker

  4. Snapshot-kontrollfilsfunktion med RMAN och ORA-00245