W3Schools
w3schools.com › postgresql › postgresql_update.php
PostgreSQL - The UPDATE Statement
The UPDATE statement is used to ... Note: Be careful with the WHERE clause, in the example above ALL rows where brand = 'Volvo' gets updated....
PostgreSQL
postgresql.org › docs › current › sql-update.html
PostgreSQL: Documentation: 18: UPDATE
May 14, 2026 - The sub-query can refer to old values of the current row of the table being updated. ... A table expression allowing columns from other tables to appear in the WHERE condition and update expressions. This uses the same syntax as the FROM clause of a SELECT statement; for example, an alias for the table name can be specified.
PostgreSQL UPDATE Query Tutorial (Day 6) | Don't Make This ...
How to Update a Record in PostgreSQL - PostgreSQL Tutorial #11 ...
10:01
Updating Existing Records | SQL Fundamentals with PostgreSQL - YouTube
10:38
UPDATE Data Options in PostgreSQL || UPDATE DML in PostgreSQL || ...
05:54
PgSQL Update Query | PgSQL Update Statement | How to Use Update ...
02:58
How to Update Records in PostgreSQL | PostgreSQL Update Records ...
DataCamp
datacamp.com › doc › postgresql › update
PostgreSQL UPDATE
UPDATE employees SET salary = 50000 WHERE employee_id = 123; This example updates the `salary` column to 50,000 for the employee with an `employee_id` of 123.
TutorialsPoint
tutorialspoint.com › postgresql › postgresql_update_query.htm
PostgreSQL - UPDATE
In PostgreSQL, UPDATE statement is used to modify or change the existing records in a table. You can use WHERE clause with UPDATE statement to update the selected rows. Otherwise, all the rows would be updated.
TechOnTheNet
techonthenet.com › postgresql › update.php
PostgreSQL: UPDATE Statement
This PostgreSQL UPDATE example would update the first_name to 'Jane' in the contacts table where the contact_id is 35.
PostgreSQL Tutorial
pgtutorial.com › home › postgresql tutorial › postgresql update statement: updating data in a table
PostgreSQL UPDATE Statement: Updating Data in a Table
January 2, 2025 - UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition RETURNING *;Code language: PostgreSQL SQL dialect and PL/pgSQL (pgsql) The following example uses the UPDATE statement to update the price of the Pixel 7 Pro product to 750 and return the updated row:
Mytechmantra
mytechmantra.com › home › postgresql › postgresql update statement tutorial
PostgreSQL UPDATE Statement Tutorial with Examples & Best Practices - MyTechMantra.com
January 6, 2026 - PostgreSQL Update Single Column Example in Employees Table ... Suppose an employee named Alice moves to the HR department. UPDATE employees SET department = 'HR' WHERE name = 'Alice'; ... The query targets the employees table.
Top answer 1 of 16
1315
The UPDATE syntax is:
[ 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 ] [, ...] ]
In your case I think you want this:
UPDATE vehicles_vehicle AS v
SET price = s.price_per_vehicle
FROM shipments_shipment AS s
WHERE v.shipment_id = s.id
Or if you need to join on two or more tables:
UPDATE table_1 t1
SET foo = 'new_value'
FROM table_2 t2
JOIN table_3 t3 ON t3.id = t2.t3_id
WHERE
t2.id = t1.t2_id
AND t3.bar = True;
2 of 16
316
The answer of Mark Byers is the optimal in this situation. Though in more complex situations you can take the select query that returns rowids and calculated values and attach it to the update query like this:
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
This approach lets you develop and test your select query and in two steps convert it to the update query.
So in your case the result query will be:
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
Note that column aliases are mandatory otherwise PostgreSQL will complain about the ambiguity of the column names.
Scaler
scaler.com › home › topics › postgresql › postgresql update query
PostgreSQL UPDATE Query - Scaler Topics
January 29, 2024 - The above query will update the salary column for the employee with employee_id equal to 101 to the new value of 60000. In PostgreSQL, the RETURNING clause is an optional part of the UPDATE query that allows you to retrieve the modified data ...
SQLS*Plus
sqlsplus.com › postgresql-update-statement
PostgreSQL UPDATE statement - SQLS*Plus
If you want to update multiple columns, you can do so by separating the column/value pairs with commas. In this PostgreSQL example of UPDATE, the value of the city will be changed to ‘Abilene’ and the state will be changed to ‘Beaumont’ where contact_id is greater than or equal to 200.
Published September 8, 2020