Was writing some SQL queries for PostgreSQL for updating some tables and did a touch of trial and error for getting the syntax right for doing a join within an update statement. Below is how I did it. I’m thinking there should be a neater way.
update table1 set columnZ = newValue from table1 t1
inner join table2 t2
on t1.columnX = t2.columnY
where table1.uniqueID = t1.uniqueID
and t2.filterColumn = filterValue
Advertisement