mysql 字符串处理
发布网友
发布时间:2022-04-23 18:56
我来回答
共4个回答
热心网友
时间:2022-04-08 05:33
-- SQL语句//建立函数
DELIMITER $$
CREATE FUNCTION `DeleteStr`(str varchar(1000)) RETURNS varchar(1000)
BEGIN
set str = replace(str,'a','');
set str = replace(str,'b','');
set str = replace(str,'c','');
set str = replace(str,'d','');
set str = replace(str,'e','');
set str = replace(str,'g','');
set str = replace(str,'g','');
set str = replace(str,'h','');
set str = replace(str,'i','');
set str = replace(str,'j','');
set str = replace(str,'k','');
set str = replace(str,'l','');
set str = replace(str,'m','');
set str = replace(str,'n','');
set str = replace(str,'o','');
set str = replace(str,'p','');
set str = replace(str,'q','');
set str = replace(str,'r','');
set str = replace(str,'s','');
set str = replace(str,'t','');
set str = replace(str,'u','');
set str = replace(str,'v','');
set str = replace(str,'w','');
set str = replace(str,'x','');
set str = replace(str,'y','');
set str = replace(str,'z','');
set str = replace(str,'A','');
set str = replace(str,'B','');
set str = replace(str,'C','');
set str = replace(str,'D','');
set str = replace(str,'D','');
set str = replace(str,'F','');
set str = replace(str,'G','');
set str = replace(str,'H','');
set str = replace(str,'I','');
set str = replace(str,'J','');
set str = replace(str,'K','');
set str = replace(str,'L','');
set str = replace(str,'M','');
set str = replace(str,'N','');
set str = replace(str,'O','');
set str = replace(str,'P','');
set str = replace(str,'Q','');
set str = replace(str,'R','');
set str = replace(str,'S','');
set str = replace(str,'T','');
set str = replace(str,'U','');
set str = replace(str,'V','');
set str = replace(str,'W','');
set str = replace(str,'X','');
set str = replace(str,'Y','');
set str = replace(str,'Z','');
return str;
END;
$$
DELIMITER ;
-- 执行函数
select DeleteStr('123a321c546e64ef316ga131a16c646j')
热心网友
时间:2022-04-08 06:51
这个字段是数据库里的某个字段的值?还是PHP里的?
如果是PHP里的先正则替换下:
<?
preg_match_all("/\d/","123a321c546e64ef316ga131a16c646j", $matches);
print_r($matches);
echo implode($matches[0],'');
?>
热心网友
时间:2022-04-08 08:26
select translate('Abcce0133','0123456789',' ') from al;
Oracle的 有translate函数 mysql不知道有这个函数没有
热心网友
时间:2022-04-08 10:17
这个我不会,关注。