I have the following table in my Postgres database
CREATE TABLE "public"."zuffs"
(
"hash" bigint NOT NULL,
"zuff" BIGINT NOT NULL,
"lat" INTEGER NOT NULL,
"lng" INTEGER NOT NULL,
"weather" INTEGER DEFAULT 0,
"expires" INTEGER DEFAULT 0,
"clients" INTEGER DEFAULT 0,
CONSTRAINT "zuffs_hash" PRIMARY KEY ("hash")
) WITH (oids = false);
to which I want to add a new row or update the weather, expires & clients columns if the row already exists. To do this I get my PHP script to generate the following SQL
INSERT INTO zuffs (hash,zuff,lat,lng,weather,expires)
VALUES(5523216,14978310951341,4978,589,105906435,4380919) ON CONFLICT(hash) DO UPDATE SET
weather = 105906435,expires = 4380919,clients = clients + 1;
which fails with the error
ERROR: column reference "clients" is ambiguous
I fail to see why this might be happening. I hope that someone here can explain