Reputation: 904
Consider the following table :
create table mixedvalues (value varchar(50));
insert into mixedvalues values
('100'),
('ABC100'),
('200'),
('ABC200'),
('300'),
('ABC300'),
('400'),
('ABC400'),
('500'),
('ABC500');
How can I write a select statement that would only return the numeric values like
100
200
300
400
500
Upvotes: 33
Views: 93224
Reputation: 41
List item has string continue with numbers
$string = "Test";
select * from table where columnname REGEXP "$string-*[0-9]+";
Upvotes: 1
Reputation: 41
SELECT * FROM mixedvalues
WHERE value > 0
ORDER BY CAST(value as SIGNED INTEGER) ASC
Upvotes: 1
Reputation: 15
You can filter your result set using the ISNUMERIC
function:
SELECT value
FROM #mixedvalues
where ISNUMERIC(value)=1
Upvotes: -4
Reputation: 2120
SELECT *
FROM mixedvalues
WHERE concat('',value * 1) = value;
Reference: Detect if value is number in MySQL
Upvotes: 9