CREATE DEFINER=`my_procedure`@`%` PROCEDURE `rescue`()
BEGIN
declare str VARCHAR(255) default '';
DECLARE n INT DEFAULT 0;
DECLARE i INT DEFAULT 0;
DECLARE cur_name VARCHAR(45) DEFAULT '';
DECLARE cur_value VARCHAR(10000) DEFAULT '';
SELECT COUNT(*) FROM tableA INTO n;
SET i=0;
WHILE i<n DO
SELECT namea,valuea FROM tableA limit i,1 INTO cur_name,cur_value;
UPDATE tableB SET nameb=cur_name where valueb=cur_value;
SET i = i + 1;
END WHILE;
END