另外,如果字符串包含多个数字,我再次修改为仅提取一个数字。如果存在一些字符或字符串预区分,您可以调用函数,其中 EXTRACT_NUMBER(SUBSTRING_INDEX(Notas,'CHARS',-1)) 是 CHARS 前字符
DELIMITER $$
DROP FUNCTION IF EXISTS `EXTRACT_NUMBER`$$
DELIMITER $$
CREATE FUNCTION EXTRACT_NUMBER(input VARCHAR(255))
RETURNS VARCHAR(255)
BEGIN
DECLARE output VARCHAR(255) DEFAULT '';
DECLARE iterator INT DEFAULT 1;
WHILE iterator < (LENGTH(input) + 1) DO
IF SUBSTRING(input, iterator, 1) IN (',', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ) THEN
IF (SUBSTRING(input, iterator, 1) = ',' AND output = '')
THEN SET output = '';
END IF;
SET output = CONCAT(output, SUBSTRING(input, iterator, 1));
END IF;
IF (SUBSTRING(input, iterator, 1) NOT IN (',', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ) AND output <> '')
THEN SET iterator = LENGTH(input);
END IF;
SET iterator = iterator + 1;
END WHILE;
RETURN replace(output,',','.');
END $$