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.
This is the way: SELECT * FROM TABLE_NAME WHERE NOT REGEXP_LIKE(COLUMN_NAME, '^-?[0-9.]+$ '); This also excludes values which contain decimals.
SQL Server has an ISNUMERIC() function that returns 1 for numeric values and 0 for non-numeric values.
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.
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.
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:]]'
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