cipriano
cipriano

Reputation: 111

sql like pattern match numbers

I am trying to match sql pattern with like: LIKE '%\"email\";s:[1-9]:%'

The string in the database is like this: "email";s:15:

But is not working to see if between s:[1-9]: are any numbers greater than 1 or if there are any numbers.

Any help appreciated

Upvotes: 1

Views: 1904

Answers (2)

Vamsi Prabhala
Vamsi Prabhala

Reputation: 49260

Use a regex match.

where col_name regexp '"email";s:[2-9]:|"email";s:[1-9][0-9]+:'

Upvotes: 1

Bill Karwin
Bill Karwin

Reputation: 562358

The LIKE comparison operator does not recognize regular expression syntax. It only recognizes wildcards _ and %.

You need to use RLIKE or REGEXP (they're actually synonyms).

You can read about them here: https://dev.mysql.com/doc/refman/5.7/en/regexp.html

Upvotes: 1

Related Questions