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); |
相关文章
- 09-02哈希表-存储自定义对象
- 09-02数据存储roadmap
- 09-02信息的表示和处理之信息存储
- 09-02GlusterFS-分布式存储集群部署
- 09-02大数据存储利器 - Hbase 基础图解
- 09-02GlusterFS 存储结构原理介绍
- 09-02分布式存储之GlusterFS
- 09-02GlusterFS分布式存储学习笔记
- 09-02GlusterFS分布式存储集群部署记录-相关补充
- 09-02Hive压缩和存储