在插入时:将列引用“得分”模棱两可

编程入门 行业动态 更新时间:2024-10-11 15:24:55
本文介绍了在插入时:将列引用“得分”模棱两可的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

在插入时:将列引用“得分”模棱两可

本文发布于:2023-10-18 04:21:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1503086.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:入时   模棱两可   得分

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!