Skip to content

Instantly share code, notes, and snippets.

@danielbaccin
Created November 5, 2015 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielbaccin/2dd756dd2f435759fe7f to your computer and use it in GitHub Desktop.
Save danielbaccin/2dd756dd2f435759fe7f to your computer and use it in GitHub Desktop.
updating table rows in postgres using subquery
UPDATE produto
SET stf_codigo = subquery.situacao
FROM (select p.procod as produto, s.stf_codigo as situacao from produto p
inner join situacao_fiscal s on (p.trbid = s.trbid)) AS subquery
WHERE produto.procod = subquery.produto;
http://stackoverflow.com/questions/6256610/updating-table-rows-in-postgres-using-subquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment