不使用游标,多张表的多条记录更新

原创
2016-06-07 15:29:18 626浏览

BEGINFOR c IN (select distinct t2.name,t1.idfrom table1 t1,table2 t2where t1.id = t2.id)LOOPupdate table1 set name = c.name where id = c.id;END LOOP;END;

BEGIN
FOR c IN 
(
select distinct t2.name,t1.id
from table1 t1,
table2 t2
where t1.id = t2.id
)
LOOP
update table1 set name = c.name 
where id = c.id;
END LOOP;
END;

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。