gpt4 book ai didi

sql - Postgres ON CONFLICT 设置列引用不明确

转载 作者:行者123 更新时间:2023-12-03 22:09:37 25 4
gpt4 key购买 nike

我有一张 table :

create table c (
e text not null,
m text not null,
p numeric not null,
PRIMARY KEY (e, m)
);

我想做插入或更新添加 p到现有值:
insert into c values (...) on conflict (e, m) do update set
p = p + excluded.p

我得到一个错误:

ERROR: column reference "p" is ambiguous



它是如何模棱两可的?我应该如何写我的插入添加 excluded.p到已经存在的值(value)?

最佳答案

好吧,你可能想要:

        p = c.p + excluded.p

您可能想要:
        p = excluded.p + excluded.p

您需要指定。

关于sql - Postgres ON CONFLICT 设置列引用不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55343169/

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