UPDATE
databaseA.table1 as a,
databaseB.table2 as b,
databaseA.table3 as c,
databaseB.table4 as d
SET a.origin = b.tui
WHERE a.contacts_id = c.contacts_id
and d.mobile = c.telephone
and d.uid = b.uid