Let's say I have table table1 with columns id, value and table2 with columns table1_id, value.
How would I write Postgresql query to update table1.value (whole table, not just one row) with table2.value if they are matching on table1.id = table2.table1_id?
Thank you for answers in advance!
You use a from clause. In Postgres, this looks like:
update table1
set col1 = . . .
from table2
where table1.id = table2.table1_id
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With