user11035754
user11035754

Reputation: 227

Include only records having letters and ignore the ones having numbers in a column

The data contains a column 'product_name' with data type string. It has strings having letters, alphanumeric strings, and numeric strings. I want to exclude the numeric string records and include all others. Below is an example-

product_name
 cell phone
 Headphones
   12356
  ABC56TV
   2345

Expected Result-

product_name
 cell phone
 Headphones
  ABC56TV

How to fetch this result?

Upvotes: 0

Views: 543

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1271241

You can use regexp_contains():

select t.*
from t
where not regexp_contains(product, '^[0-9]+$');

This matches something that is not all digits.

Upvotes: 4

Related Questions