0

For examle my table at MySQL has values like;

>  Foobar is cool
>  foobar was in here
>  Bla bla bla

I need result where search text is "foobar" even if user misspelled as "fobar"

   >  Foobar is cool
   >  foobar was in here
mgunduz
  • 28
  • 8
  • Unfortunately there is no spell checker built into mysql. So you would need to use something similar to the following: SELECT * FROM table WHERE column LIKE 'f%bar' OR column LIKE 'f%ar'... etc. – Garrett R. Davis May 01 '16 at 02:16
  • i read some articles about levenshtein and similar_text() functions. I am not sure but these may helps for solution. – mgunduz May 01 '16 at 02:19

1 Answers1

1

You could use a levenshtein function which returns the minimal number of character changes needed to transform one word into another word.

One implementation is shown here https://stackoverflow.com/a/4671557/5546380

This example just compares two words so you'd need to either modify this function or create a new one that calls this one and performs the levenshtein on each word within the field and return if it passes a certain threshold, for example 1 character change for "fobar" to be "foobar", 2 for "foba" to be "foobar".

Community
  • 1
  • 1
Ryan Jenkin
  • 864
  • 8
  • 11