mysql存儲過程:復制表A的某列到表B中去 這是一個存儲過程,用於將tableA表中avalue列的值復制到tableB表中的bvalue列(假設tableA和tableB中都有相同的列,名為id) [sql] create procedure copy_field() begin declare tid int default 0; declare tvalue int default 0; declare b int default 0; declare cur cursor for select a.id, a.avalue from tableA as a join tableB as b where a.id=b.id; DECLARE CONTINUE HANDLER FOR NOT FOUND SET b = 1; open cur; set b = 0; repeat FETCH cur INTO tid, tvalue; update tableB set bvalue=tvalue where id=tid; until b>0 end repeat; close cur; end