update aTable a
innerjoin bTable b on a.id = b.id
innerjoin cTable c on b.define1 = c.subcode
innerjoin dTable d on d.id = c.subcode
set a.Demand_orgid = c.req_org_id
where xxx = xxx;
-- 创建临时表CREATETEMPORARYTABLE tempTable0(select a.resid,b.define1,c.reqid,a.id from tableA a
innerjoin tableB b on a.id = b.id
innerjoin tableC c on c.id = b.id
where c.id <>'10086'-- 查看你的临时表:select*from tempTable0;
然后你就有了一张可以随便玩的临时表。
最后写更新语句的时候,只需要写一个inner join,连接这个临时表,就可以实现复杂数据更新了:
update tableA a
innerjoin tempTable0 b on a.id = b.id
set a.Demand_orgid = b.req_org_id;