Update from the comparison between two postgres tables

2

I have a sales table that contains the salesperson's code.
But the seller's table was completely redone, with the change of id .

How can I update the vendor code in the sales table from the comparison between the new vendor table and the old one?

I tried doing join but it was made update with the same id of seller for all records of the vendas table.

    
asked by anonymous 19.09.2016 / 20:07

1 answer

0

To be used JOIN you must have a relationship between tables, otherwise you will not be able to, see how it can be done:

UPDATE Vendas set camposVendas = novoValor,... JOIN TabelaVendedor1 as TB1 ON TB1.campoVerifica = campoTabelaVenda ou TB2 JOIN TabelaVendedor2 as TB2 ON TB2.campoVerificad = campoTabelaVenda ou TB1

Remember, there must be relationships between these tables for this statement to work. I hope I have helped!

    
19.09.2016 / 20:27