Shubham Ringne Shubham Ringne - 1 month ago 6
MySQL Question

MySQL - Select only non - numeric values from varchar column

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.

Answer

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:]]'