Update a column of a table with a column of another table in PostgreSQL
Your UPDATE query should look like this: UPDATE table2 t2 SET val2 = t1.val1 FROM table1 t1 WHERE t2.table2_id = t1.table2_id AND t2.val2 IS DISTINCT FROM t1.val1; — optional, see below The way you had it, there was no link between individual rows of the two tables. Every row would be fetched from table1 for … Read more