0

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 ?

pirho
  • 11,565
  • 12
  • 43
  • 70

1 Answers1

2

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'),'%')
Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133