0

I found this query in mysql query log and I will like to know what exactly does it do.

select * from tblname WHERE TRIM(NAME) REGEXP 'John[      ]*Smith'

1 Answer 1

3

It selects all rows from tblname where name (with spaces around removed, if any) equals to John<any number of spaces>Smith

So you'll find JohnSmith as well as John_________________________Smith (stackoverflow eats repetitive spaces, so I replaced them with underscore).

The regex itself is a little bloated and can be rewritten as John *Smith

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

1 Comment

You could even skip the character class :P

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.