1

Sure, I can write a function for it in Python or something...but how can I do it in MYSQL?

WHERE title = "heart of darkness" more or less 3 characters...
TIMEX
  • 259,804
  • 351
  • 777
  • 1,080

1 Answers1

0

A similar issue was discussed in this SO question, and here's a link from the accepted answer that presents a computation of Levenshtein distance in MYSQL.

Personally, however, I would avoid the stored-procedure approach and just implement it in the driving language (be it Python, PHP or whatever you use to interface the DB).

Community
  • 1
  • 1
Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
  • Was looking for this answer or similar (dice-coefficient) - if you store the bi-grams in a db table with a key back to the whole text string you wish to search, you can do a simple sql statement like: select count(bigr_ids) hits,search_txt_id from bigram_table where bigram in ('ab','bc','de'...) group by search_txt_id order by hits desc and take advantage of the db indexing to search/sort/match bigrams for you. This is especially helpful when the list of possible matches grows large (above several thousand). HTH helps someone else – Ross Apr 04 '12 at 13:35