Quantcast
Channel: How to do an update + join in PostgreSQL? - Stack Overflow
Viewing all articles
Browse latest Browse all 19

Answer by Fast Engy for How to do an update + join in PostgreSQL?

$
0
0

For those actually wanting to do a JOIN you can also use:

UPDATE aSET price = b_alias.unit_priceFROM      a AS a_aliasLEFT JOIN b AS b_alias ON a_alias.b_fk = b_alias.idWHERE a_alias.unit_name LIKE 'some_value'AND a.id = a_alias.id;

You can use the a_alias in the SET section on the right of the equals sign if needed.The fields on the left of the equals sign don't require a table reference as they are deemed to be from the original "a" table.


Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>