Is there a way to detect if a value is a number in a MySQL query? Such as
SELECT * FROM myTable WHERE isANumber(col1) = true
Advertisement
Answer
This should work in most cases.
SELECT * FROM myTable WHERE concat('',col1 * 1) = col1
It doesn’t work for non-standard numbers like
1e4
1.2e5
123.
(trailing decimal)