I have a problematic script that ran, so i need to select all rows that contain values that is not a straight up integer. How do I do this? ISSTRING was on a Google search but I get an error from it saying ISSTRING does not exist. :(
So far I've muddled with:
SELECT id, area, city FROM `homes` WHERE ISSTRING(`area`) OR ISSTRING(`city`)
With no luck whatsoever...
Syntax to check if the value is an integer. select yourColumnName from yourTableName where yourColumnName REGEXP '^-?[0-9]+$'; The query wherein we have used regular expression. This will output only the integer value.
The symbol <> in MySQL is same as not equal to operator (!=). Both gives the result in boolean or tinyint(1). If the condition becomes true, then the result will be 1 otherwise 0. Case 1 − Using != operator.
To check records which are NULL, use IS NULL. However, to exclude any of the records, use the NOT IN clause. Use both of them in the same query.
To find the number of columns in a MySQL table, use the count(*) function with information_schema. columns and the WHERE clause.
RegExp works, but what I would do is check to see if abs() is equal to zero AND the field is not zero. I think this will be faster than RegExp.
SELECT id, area, city FROM `homes` WHERE (abs(area) = 0 AND area != '0') OR (abs(city) = 0 AND city != '0')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With