Skip to content
Advertisement

How to update each row that shares the same id differently in postgresql?

Hope this isn’t too hard to explain. I need to update the first table with addresses from the second

So basically I have mytable1 that has the following columns:

And then I have mytable2 that actually has the correct addresses:

I need to fill mytable1 with the correct addresses in mytable2 and they have the super_id in common

However when I try to do

It returns an error because obviously super_id is duplicated

Is there a way to update all address rows into mytable1? An insert could probably work but there’s already a lot of data on mytable1

Advertisement

Answer

This is tricky. If I understand correctly, you need to enumerate each of the tables for the update:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement