mysql存储过程实例
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);
相关推荐
唐文 2020-02-20
chenluhe 2019-09-05
mysqllover 2019-04-14
xiaobaif 2019-04-15
variab 2019-03-25
码农专业户 2011-12-04
愿天下再无BUG 2016-04-13
xjywp00 2019-06-20
无崖子 2018-10-23
sofast 2014-09-18
KevinMitnick 2018-08-10
这些年来 2012-08-31
wyywn 2012-05-19
hwj 2012-05-19
babyZeng 2011-12-14
fuguangruomeng 2019-04-16
gmysql 2011-10-06
zhangweijin 2011-10-06