0

I have a column like this:

WW0476091
YA0457514
547856232
856987452
254785W11

I want to get the values that contain numerals only (decimal digits from 0 to 9). For the example above, I want only these records to be printed:

547856232
856987452

How can I do that?

4
  • I removed the tags for sql-server and mysql as you stated previously that you are using Postgres. Please only add tags for the DBMS you are actually using Jan 30, 2020 at 11:57
  • where the_column in ('547856232', '856987452')? Jan 30, 2020 at 11:58
  • i have 50 lakhs records... i have to get a count of ones that are only numeric and avoid alphanumerics Jan 30, 2020 at 12:01
  • 1
    Numeric == only digits? no minus, decimal point, leading/trailing spaces, etc.?
    – Akina
    Jan 30, 2020 at 12:27

1 Answer 1

1

You can use a regular expression for that:

select *
from the_table
where the_column ~ '^[0-9]+$';

Related question on Stackoverflow

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.