This is a mysql function:
delimiter //
create function IF NOT EXISTS LeaveNumber(str varchar(50)) returns varchar(50)
no sql
begin
declare verification varchar(50);
declare result varchar(50) default '';
declare character varchar(2);
declare i integer default 1;
if char_length(str) > 0 then
while(i <= char_length(str)) do
set character = substring(str,i,1);
set verification = find_in_set(character,'1,2,3,4,5,6,7,8,9,0');
if verification > 0 then
set result = concat(result,character);
end if;
set i = i + 1;
end while;
return result;
else
return '';
end if;
end //
delimiter ;
select leaveNumber('fAX:-12abcDE234'); -- RESULT: 12234
Use it as a native mysql function in your update query.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…