Home > database >  From a MySQL table update field to another table, two tables are the data volume
From a MySQL table update field to another table, two tables are the data volume

Time:09-19

Update student s, city c
Set s.c ity_name=c.n ame
Where s.c ity_code=Arthur c. ode;

This method will cause the city locked, what solution can be avoided, reducing the MySQL data isolation level is the best?

CodePudding user response:

Don't understand your business logic, if the student. The code is number type, you can try this,

DECLARE
The begin
FOR i IN 0.. 99 LOOP
Update student s, city c
Set s.c ity_name=c.n ame
Where s.c ity_code=Arthur c. the ode and mod (s.c ity_code, 100);
END LOOP;
end ;
  • Related