I see that within MySQL there are Cast()
and Convert()
functions to create integers from values, but is there any way to check to see if a value is an integer? Something like is_int()
in PHP is what I am looking for.
I'll assume you want to check a string value. One nice way is the REGEXP operator, matching the string to a regular expression. Simply do
select field from table where field REGEXP '^-?[0-9]+$';
this is reasonably fast. If your field is numeric, just test for
ceil(field) = field
instead.