MySQL Batch update data
My database has a ydd field, and the values in the fields are similar: 5456 Huainan District
I want to filter out the numbers in the field in the MySQL batch.
How does it come true, please?
------Solution--------------------
The first time to write MySQL function, dedicated to the landlord you ~ very stupid method to achieve
SQL Code
SET GLOBAL log_bin_trust_function_creators=true;drop function IF EXISTS num_fiter; CREATE FUNCTION num_fiter (input varchar (255)) RETURNS varchar (255) BEGIN DECLARE i INT; DECLARE length INT; DECLARE current VARCHAR (1); DECLARE temp VARCHAR (255); SET i=0; SET temp= "; SET length=length (input); While I <= length does SET current=substr (input from I for 1); IF current REGEXP ' [0-9] ' then SET current= '; END IF; SET Temp=concat (temp,current); SET i=i+1; END while; RETURN temp; END; SELECT num_fiter (' 5456 Huainan District ');