There’s no function at MySQL that can do the same thing as IsNumeric() from SQL Server or the is_numeric() from PHP, but there’s a way to work the way around.

When I started researching for this particular function, I needed to check for any accounts that had a bad format type for the phone. In this case the phone had to be all numbers only.

The trick to check for this on MySQL is simple, just convert the field to a integer type, but there’s a catch it will only work for integer numbers.

This is how you would do the query.

SELECT * FROM the_table
WHERE 1
AND CONVERT(some_field, SIGNED INTEGER) IS NOT NULL

This will return all rows that have the field correctly set to a number format.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]


Leave a Comment

You must be logged in to post a comment.

blank