Find similar word in a MYSQL statement

Question:

Well, I have a table of vehicles and I have the record called landroad. Well, doing a SELECT * FROM VEHICULOS WHERE NOMBRE LIKE ='%landroad%' works.

What I am looking for is that a result appears even if the user has misspelled the name, and that if the sentence finds a similarity, it shows it. In a nutshell, I'm looking for

SELECT * FROM VEHICULOS WHERE NOMBRE LIKE = '%ladroad%' 

return the same result as the query above.

Answer:

It is possible but for me it would be very difficult and tedious to give you an example.

There is something called " levenshtein distance " which is a distance that evaluates the minimum number of operations needed to transform from one word to another. So the word with the minimum distance would be the one that would be searched for instead… it's very tedious in SQL.

And here is an implementation in SQL.

Perhaps something that can be "useful" for you, and "easier" to implement, is a table of "similar words/terms".

Scroll to Top