Answer the question
In order to leave comments, you need to log in
mysql. How to select rows in a field that contains only numbers?
Let's say the table has a first_letter field, which can be either a number or a letter. How to select only those lines for which first_letter=number?
Answer the question
In order to leave comments, you need to log in
firstr_letter only one character?
test the following constructs for speed:
- WHERE first_letter IN (1,2,3,4,5,6,7,8,9,0)
- WHERE first_letter REGEXP '[0-9]'
something like this:
SELECT * FROM ... WHERE first_letter REGEXP '^[0-9]+$';
and if there is only one character, then you can simply
SELECT * FROM ... WHERE first_letter REGEXP '^[0-9]';
Regular expressions are not the best idea (see EXPLAIN).
select * from t where str<='9'
select * from t where str in ('0','1','2','3','4','5','6','7' ,'8','9')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question