user3401592
user3401592

Reputation: 29

Mysql like operator didn't find a match

I have to search in database some name. If I write

LIKE '%Alex Maxim%' - success.

If I write:

LIKE '% Alex Maxim%' - null.

I think is from the first white spaces('% Al...').

How can I do this ?

Upvotes: 0

Views: 73

Answers (1)

Mudassir Hasan
Mudassir Hasan

Reputation: 28771

Remove whitespaces using TRIM() string function

LIKE CONCAT('%',TRIM(' Alex Maxim'),'%')

If you want to remove only leading whitespace then use LTRIM() function

LIKE CONCAT('%',LTRIM(' Alex Maxim'),'%')

Upvotes: 2

Related Questions