0

I have this script:

df1 = spark.sql("select * from table where field LIKE '%[0-9]%'") display(df1) 

This gives me empty DF. I have table contains:
enter image description here

2
  • What is the exact data-type of the field column? What DBMS are you using? Commented Jul 15, 2021 at 15:25
  • do you want to match if string contain a single digit? Commented Jul 16, 2021 at 17:53

1 Answer 1

3

If you want to return rows where the field has at least one digit, then you should use regular expressions. That is RLIKE and regular expression syntax:

select * from table where field rlike '[0-9]' 

None of your fields contain the subquery '[0-9]' so none match like, which does not support [].

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.