Home > Database > Mysql Tutorial > 不使用游标,多张表的多条记录更新

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-07 15:29:18
Original
953 people have browsed it

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;
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template