How to create a function to determine if a value is numeric in MySQL/SQL

This is how you can create a function in MySQL to determine if a selected value is numeric or not.

<?php
CREATE
FUNCTION IsNumeric (sIn varchar(1024)) RETURNS tinyint DETERMINISTIC
RETURN sIn REGEXP '^(-|\\+){0,1}([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$';

UPDATE nodemap SET`nodemap_city` = CONCAT(SUBSTR(`nodemap_city`, 1, 3), ' ', SUBSTR(`nodemap_city`, 4, 2), SUBSTR(`nodemap_city`, 6)) WHERE IsNumeric(SUBSTR(`nodemap_city`, 1, 5)) = 1 LIMIT 1;
?>
Knowledge keywords: