UPDATE with FROM
UPDATE with FROM is a SQL statement in the DML Statements category. Updates a table using values from another table via a join. PostgreSQL/SQL Server syntax. The syntax is UPDATE t1 SET t1.col = t2.val FROM table1 t1 JOIN table2 t2 ON t1.id = t2.id;. It returns rows updated. A typical example: UPDATE employees e SET salary = s.new_salary FROM salary_adjustments s WHERE e.id = s.employee_id; -- Bulk update salaries from adjustments table A close relative is INSERT INTO, which inserts new rows into a table. A close relative is UPDATE, which modifies existing rows in a table. Always use WHERE to avoid updating all rows. A close relative is DELETE, which removes rows from a table. Always use WHERE to avoid deleting all rows. More about this category: Data Manipulation Language — INSERT, UPDATE, DELETE, REPLACE, MERGE. Related DML Statements entries: INSERT INTO, UPDATE, DELETE, REPLACE INTO, INSERT ... ON DUPLICATE KEY UPDATE, MERGE, INSERT INTO SELECT, UPSERT (PostgreSQL).