I'm using MonetDB 11.33.3 (April 2019 release). I want to update records in some table, using corresponding values from another table.
Specifically, and for example, suppose table1
has columns col1
, col3
and table2
has columns col2
, col4
. Assume that there's an injective map from the values of table1.col3
to table2.col4
(so that when we equi-join with these columns we get at most one match). I want to set table1.col1
to the corresponding table2.col3
value - from the single matching record in table2
(using the equi-join I just mentioned).
Here is my attempted query:
WITH t2 AS (SELECT * FROM table2)
UPDATE
table1
SET
col1 = t2.col2
WHERE
col3 = t2.col4
;
this gives me:
SELECT: identifier 'col1' unknown
I don't understand why I'm getting this particular error, and thus don't understand what I've gotten wrong or how to fix the query.