1

I have a table with two columns:

Name | Type

Now I am querying this table from an autocomplete HTML form and I would like to get a result similar to this pseudo query.

SELECT 10 Closest_Names FOR EACH TYPE WHERE Names LIKE INPUT

Any idea how the real query would look like?

El Dude
  • 5,328
  • 11
  • 54
  • 101
  • What do you mean by "closest names"? I don't think you can query MySQL directly for that. Maybe you're looking for the levenshtein function : http://stackoverflow.com/questions/18757251/php-using-levenshtein-distance-to-match-words – Christian Bonato Jun 23 '14 at 23:51
  • 1
    This question might help you: http://stackoverflow.com/questions/3140589/mysql-query-select-top-3-rows-from-table-for-each-category – scrowler Jun 23 '14 at 23:56
  • Thanks for the levenshtein hint. I bet it's useful, but the delay generated might be too long for a autocomplete query. Thanks :) – El Dude Jun 24 '14 at 00:04
  • I think mysql's [FULL TEXT support](http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html) will do this kind of thing. – Lee Jun 24 '14 at 00:09

1 Answers1

0

i have a experience in autocomplete that value comes from database you are asking for QUERY right? here's my example, i hope it will help

SELECT name,type FROM <table> WHERE name like '%input%' LIMIT 10
wrecklez
  • 343
  • 2
  • 4