当前位置:Gxlcms > mysql > 不使用游标,多张表的多条记录更新

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

时间:2021-07-01 10:21:17 帮助过:28人阅读

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;

  1. BEGIN
  2. FOR c IN
  3. (
  4. select distinct t2.name,t1.id
  5. from table1 t1,
  6. table2 t2
  7. where t1.id = t2.id
  8. )
  9. LOOP
  10. update table1 set name = c.name
  11. where id = c.id;
  12. END LOOP;
  13. END;

人气教程排行