MySQL SELECT Query – How to Match String with User Input

likeMySQLselect

My online-shop in PHP (OpenCart). On site we have product-search. For example product have name iSport 220, and if user search input string is iSport220 we must show this product. And vice versa.

First my thought was about LIKE operator, but I see that I need something different. In list of MySQL string functions I do not find any useful. What the best practice for this kind of problem? Version of MySQL is 5.5.

Best Answer

Replace space and compare: ... where replace('xxx yyy',' ','') = 'xxxyyy'

or generally it can be: ... where replace(column,' ','') = 'xxxyyy'

But not that this may not like your indexes on the columns.