在插入时:将列引用“得分”模棱两可 [英] On Insert: column reference "score" is ambiguous

查看:93
本文介绍了在插入时:将列引用“得分”模棱两可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在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

这篇关于在插入时:将列引用“得分”模棱两可的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆