MySQL Select only non-numeric values ​​from the 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 (alphanumeric) values, i.e. ABC100, EFEA200, AAFASF300, AERG400, AGE500.

I have code to select numerical values, i.e. 100 200 ....

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

Please help me, I'm starting.

+6
source share
1 answer

The regular expression [a-zA-Z] should only run true if the value contains at least one letter.

 SELECT * FROM mixedvalues WHERE value REGEXP '[a-zA-Z]'; -- or REGEXP '[[:alpha:]]' 
+5
source

Source: https://habr.com/ru/post/1011544/


All Articles