Reputation: 29
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
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