Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get non-numeric entries in a column of a database

I have customer database that we use for auto-charges. It would appear that the CC expiration field has a couple records with invalid entries for expiration date... for example non-numeric. Is there a way to search for entries with a NON-Numeric value? Below is the start of how I would assume the query would look...

select *
from customers
where ccexperiation = non numeric

Thanks.

like image 424
Shmewnix Avatar asked Nov 28 '12 13:11

Shmewnix


People also ask

How do I find non-numeric values in a column in SQL?

This is the way: SELECT * FROM TABLE_NAME WHERE NOT REGEXP_LIKE(COLUMN_NAME, '^-?[0-9.]+$ '); This also excludes values which contain decimals.

How do I select only numeric values in a column in SQL?

In SQL Server, we can use the ISNUMERIC() function to return numeric values from a column. We can alternatively run a separate query to return all values that contain numeric data.


1 Answers

select *
from customers
where ISNUMERIC(ccexperiation) = 0

With some minor caveats. See here.

like image 178
Will A Avatar answered Oct 13 '22 23:10

Will A