-2

I have a table with varchar column, this column contains both numeric records and AlphaNumeric records, but require only the ones that have no letters. How can I achieve this?

Cor Cool
  • 33
  • 7
  • 1
    Sorry, that doesn't make much sense? Can you clarify your question please. – BenM Dec 10 '13 at 14:01
  • Its usually pretty bad practice to do this, you should really ensure that if you want something in a particular format you set the column with this type – Melbz Dec 10 '13 at 14:05
  • possible duplicate of [Detect if value is number in MySQL](http://stackoverflow.com/questions/5064977/detect-if-value-is-number-in-mysql) – M Khalid Junaid Dec 10 '13 at 14:06

3 Answers3

3

Try this:

SELECT * FROM table WHERE `varcharcol1` RLIKE '^[0-9]+$'
Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
2

tryed

SELECT column_name FROM table WHERE ISNUMERIC(column_name) = 1
2
select * from table where concat('', column * 1) = column;

Returns array of data, where column is numeric (contains only digits).

Victor Perov
  • 1,697
  • 18
  • 37