I would like to create a function where, if a user search for Nicklas, and if no matches, following suggestions should be printed to the user: Nicoline, Nicky etc. (all entries in the database) - Basically closest matches to a string.
Using a Like operator in Mysql, is close, but if there is no result, simply no results would be shown:
SELECT * FROM employees WHERE fullname LIKE '%Nicklas%'
I need somehow to expand the Like to come up with the closest names in the database, that matches the string the user types in.
ElasticSearch/Algolia has this functionality, but this is custom needed. Would would be the best way if implementing this?
I thought about using an PHP Explode of the sentence, and then LIKE in sql (left and right), but I think that would create unwanted results (duplicates).