1
I have a field with information in this pattern: "PLC__Line" 34355655413.3912
.
What can I use to take out the letters, _ and " in a select, leaving only the numbers and the dot?
In Postgresql I know there is the Translate function, but what can be done in MYSQL?
Edit 1: With Function below I managed to get the lyrics out, but the point is also gone, and it’s important. How can I edit this Function so that it also leaves the point?
DELIMITER $$
CREATE FUNCTION `testdb`.`GetNumber` (field varchar(100))
RETURNS VARCHAR(100)
BEGIN
DECLARE ls INTEGER;
DECLARE i INTEGER;
DECLARE str varchar(100);
SET ls = (select length(field));
SET i = 1;
SET str = "";
WHILE i <= ls DO
IF ((substring(field, i,1) REGEXP '[0-9]') <> 0) THEN
SET str = CONCAT(str, convert(substring(field, i,1) USING UTF8));
END IF;
SET i = i + 1;
END WHILE;
RETURN str;
END;
That text
"PLC__Line"
is standard or it can change?– Pedro Paulo
Searching a little more I discovered here in the forum a question equal to yours and with an answer that was accepted, follow the link: Answer
– R.Santos
Peter, it can change.
– Anônimo