I'm trying to replicate this answer using postgreSQL and psycopg2: https://mcmap.net/q/970250/-is-it-possible-to-update-rows-from-a-key-value-pair
My SQL code looks like (I just put the new line here for better readibility):
UPDATE t SET mycolumn = a.mycolumn FROM mytable AS t INNER JOIN (VALUES (28625, '1'),
(56614, '1'), (86517, '1') ) AS a(id, mycolumn) ON a.id = t.id
However, I'm getting the next error:
psycopg2.errors.UndefinedTable: relation "t" does not exist
when executing this sql with my cursor. In mytable I have a column with the name mycolumn and another one with name id, which is the primary key. What am I missing? By the way, the order of the couples should be like this, no? Just asking because in the previous answer I think the user exchanged the id and value values.
ON a.id = id
. – Quinidine