为找教程的网友们整理了mysql实例相关的编程文章,网友景德佑根据主题投稿了本篇教程内容,涉及到mysql存储过程实例相关内容,已被361网友关注,下面的电子资料对本篇知识点有更加详尽的解释。
mysql存储过程
delimiter $ DROP FUNCTION IF EXISTS `fun_convert`$ CREATE DEFINER=`root`@`%` FUNCTION `fun_convert`(para varchar(255)) RETURNS varchar(255) CHARSET gbk BEGIN declare result varchar(255) default ''; declare cnt int default 0; declare i int default 0; declare id BIGINT default 0; set cnt = length(para) - length(replace(para,',',''))-1; WHILE i < cnt DO select c.id into id from company c where c.code = SUBSTRING(para,i*3+2,2); set result = CONCAT(result, ",",id); set i = i+1; end WHILE; set result = CONCAT(result, ","); RETURN result; END $ delimiter ; update users u set u.company = fun_convert(u.COMPANY);