SQL query to update value based on email address in different table joined by id
I'm not sure if this solution covers your desired result:




CREATE TABLE table1 (id int, bla1 varchar(10), bla2 varchar(10), ucr varchar(10));
INSERT INTO table1 VALUES (10001, 'ABC', 33, 'VALUE1');
INSERT INTO table1 VALUES (10002, 'DEF', 44, 'VALUE2');
CREATE TABLE table2 (id int, bla1 varchar(10), bla2 varchar(10), email varchar(100));
INSERT INTO table2 VALUES (10001, 'TYU', 33, '1@1.com');
INSERT INTO table2 VALUES (10002, 'FGT', 44, '2@2.com');
CREATE TABLE dummy (ucr int, name varchar(100), email varchar(100));
INSERT INTO dummy VALUES (10001, 'ABC', '1@1.com');
INSERT INTO dummy VALUES (10002, 'DEF', '2@2.com');






UPDATE table1
JOIN   table2 
ON     table1.id = table2.id
JOIN   dummy
ON     dummy.email = table2.email
SET    table1.ucr = dummy.ucr;






SELECT *
FROM   table1;



   id | bla1 | bla2 | ucr  
----: | :--- | :--- | :----
10001 | ABC  | 33   | 10001
10002 | DEF  | 44   | 10002



dbfiddle here