您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

mysql存储过程:复制表A的某列到表B中去_MySQL

2025/11/1 22:35:57发布23次查看
bitscn.com
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
bitscn.com
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product