I have a table:
create table c (
e text not null,
m text not null,
p numeric not null,
PRIMARY KEY (e, m)
);
and I want to do insert or update that adds p
to existing value:
insert into c values (...) on conflict (e, m) do update set
p = p + excluded.p
and i get an error:
ERROR: column reference "p" is ambiguous
how it's ambiguous? how should i write my insert to add excluded.p
to the already existing value?
Well, you probably want:
p = c.p + excluded.p
It is possible that you want:
p = excluded.p + excluded.p
You need to specify.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With