gpt4 book ai didi

postgresql - 在插入 : column reference "score" is ambiguous

转载 作者:行者123 更新时间:2023-11-29 11:08:43 27 4
gpt4 key购买 nike

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

我觉得这很奇怪,因为我只使用了一张 table 。有什么想法吗?

最佳答案

set子句中=右边,score有两种可能:EXCLUDED.scoreword_relations.score。前者是一种访问被插入值的方式;后者是一种访问存储在行中的值的方法。

我会这样写:

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

关于postgresql - 在插入 : column reference "score" is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36378646/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com