本文介绍了在插入时:将列引用“得分”模棱两可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在PostgreSQL中有以下命令:
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`)我得到以下错误:
column reference "score" is ambiguous我认为这很奇怪,因为我只使用一张桌子。有任何想法吗?
I thought it was odd as I am only using one table. Any ideas?
推荐答案位于 = 右侧 set 子句,分数有两种可能: EXCLUDED.score 和 word_relations.score 。前者是一种访问所插入值的方法;
On the right side of the = in the set clause, there are two possibilities for score: EXCLUDED.score and word_relations.score. The former is a way of accessing the value being inserted; the latter a way of accessing the value stored in the row.
我将其写为:
ON CONFLICT (word1_id, word2_id) DO UPDATE SET score = word_relations.score + EXCLUDED.score更多推荐
在插入时:将列引用“得分”模棱两可
发布评论