Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - Select only non - numeric values from varchar column

Tags:

create table mixedvalues (value varchar(50));  insert into mixedvalues values ('100'); insert into mixedvalues values ('ABC100'); insert into mixedvalues values ('200'); insert into mixedvalues values ('EFEA200'); insert into mixedvalues values ('300'); insert into mixedvalues values ('AAFASF300'); insert into mixedvalues values ('400'); insert into mixedvalues values ('AERG400'); insert into mixedvalues values ('500'); insert into mixedvalues values ('AGE500'); 

i want to select only non-numeric(alpha numeric) values, i.e ABC100,EFEA200,AAFASF300,AERG400,AGE500.

i have the code for selecting numeric values, i.e 100,200....

SELECT *  FROM mixedvalues  WHERE value REGEXP '^[0-9]+$'; 

Please help me,iam a beginner.

like image 469
Shubham Ringne Avatar asked Oct 21 '16 10:10

Shubham Ringne


People also ask

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

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 find non numeric values in a numeric column in SQL?

SQL Server has an ISNUMERIC() function that returns 1 for numeric values and 0 for non-numeric values.

How do I select only the value of an integer in MySQL?

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.

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

SQL Server ISNUMERIC() Function The ISNUMERIC() function tests whether an expression is numeric. This function returns 1 if the expression is numeric, otherwise it returns 0.


1 Answers

The regex [a-zA-Z] should only fire true if a value contains at least one letter.

SELECT *  FROM mixedvalues  WHERE value REGEXP '[a-zA-Z]';   -- or REGEXP '[[:alpha:]]' 
like image 124
Tim Biegeleisen Avatar answered Oct 25 '22 17:10

Tim Biegeleisen