Skip to content
Advertisement

Column name is ambiguous on UPSERT action

I am trying to run an UPSERT query string on a postgres db –

I am basically trying to update the column average_expense if there is conflicting data, but I think there is something wrong with the query as I am running into the following error –

I believe we have to add some table name alias somewhere but I am not sure how to fix this.

Advertisement

Answer

You need to full qualify the reference to the old values (i.e. the “non-exluded” ones). This is a bit easier if you use an alias for the target table

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