In the inset: the reference to the β€œrating” column is ambiguous

I have the following command in postgresql:

INSERT INTO word_relations(word1_id, word2_id, score) VALUES($1, $2, $3) ON CONFLICT (word1_id, word2_id) DO UPDATE SET score = score + $3`) 

I get the following error:

 column reference "score" is ambiguous 

I thought this was strange since I only use one table. Any ideas?

+6
source share
1 answer

On the right side of = in the set clause, there are two possibilities for score : EXCLUDED.score and word_relations.score . The first way to access pasted value; The last way to access a value stored in a string.

I would write this as:

 ON CONFLICT (word1_id, word2_id) DO UPDATE SET score = word_relations.score + EXCLUDED.score 
+18
source

All Articles