广州传奇网络
地址:广州市天河区东圃大马路富华楼C座
电话:13808825895
QQ:1564443073
首先开启自定义函数开关
SET GLOBAL log_bin_trust_function_creators = 1
SET GLOBAL log_bin_trust_function_creators = 1
CREATE FUNCTION `concat_ic`(goods_name varchar(64)) RETURNS varchar(64) CHARSET utf8
BEGIN
DECLARE temp varchar(64);
set temp = replace(goods_name,"#","");
set temp = replace(temp,".","");
set temp = replace(temp,"/","");
set temp = replace(temp,"-","");
set temp = replace(temp,"=","");
set temp = replace(temp,"_","");
set temp = replace(temp," ","");
set temp = replace(temp,"+","");
set temp = replace(temp,"(","");
set temp = replace(temp,")","");
set temp = replace(temp,"!","");
set temp = replace(temp,"\"","");
set temp = replace(temp,"$","");
set temp = replace(temp,"%","");
set temp = replace(temp,"&","");
set temp = replace(temp,"'","");
set temp = replace(temp,"*","");
set temp = replace(temp,",","");
set temp = replace(temp,":","");
set temp = replace(temp,";","");
set temp = replace(temp,"<","");
set temp = replace(temp,"\|","");
set temp = concat("€€",temp);
set temp = concat(goods_name,temp);
return temp;
end
我们在检索ecshop商品的时候,select goods_id,concat_ic(goods_name) from ecs_goods就可以直接调用mysql自定义函数了。