0

This works:

mysql> SELECT '123456789' REGEXP '.{3}';#1

mysql> SELECT '123456789' REGEXP '.{10}';#2

but not this:

mysql> SELECT * FROM mymodel WHERE some_text_field REGEXP '.{100}';#3

throwing exception: ERROR 1139 (42000): Got error 'invalid repetition count(s)' from regexp

1 Answer 1

1

It means you don't have a string which is 100 characters or more in this field.
You could try this instead, if you just want to check this condition:

SELECT * FROM mymodel WHERE LENGTH(some_text_field) = 100 ;
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, this worked for me. But i am just curious about the above queries. #1 gives 1, #2 gives 0 as results but #3 throws exception. If there are no matching rows, then answer should be 0, it shouldn't throw an exception.
I agree with that, it's kinda nasty :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.