Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can start with using <a href="http://en.wikipedia.org/wiki/Soundex" rel="noreferrer"><code>SOUNDEX()</code></a>, this will probably do for what you need (I picture an auto-suggestion box of already-existing alternatives for what the user is typing).</p> <p>The drawbacks of <code>SOUNDEX()</code> are:</p> <ul> <li>its inability to differentiate longer strings. Only the first few characters are taken into account, longer strings that diverge at the end generate the same SOUNDEX value</li> <li>the fact the the first letter must be the same or you won't find a match easily. SQL Server has DIFFERENCE() function to tell you how much two SOUNDEX values are apart, but I think MySQL has nothing of that kind built in.</li> <li>for MySQL, at least according to <a href="http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_soundex" rel="noreferrer">the docs</a>, SOUNDEX is broken for unicode input</li> </ul> <p>Example:</p> <pre><code>SELECT SOUNDEX('Microsoft') SELECT SOUNDEX('Microsift') SELECT SOUNDEX('Microsift Corporation') SELECT SOUNDEX('Microsift Subsidary') /* all of these return 'M262' */ </code></pre> <p>For more advanced needs, I think you need to look at the <a href="http://en.wikipedia.org/wiki/Levenshtein_distance" rel="noreferrer">Levenshtein distance</a> (also called "edit distance") of two strings and work with a threshold. This is the more complex (=slower) solution, but it allows for greater flexibility.</p> <p>Main drawback is, that you need both strings to calculate the distance between them. With SOUNDEX you can store a pre-calculated SOUNDEX in your table and compare/sort/group/filter on that. With the Levenshtein distance, you might find that the difference between "Microsoft" and "Nzcrosoft" is only 2, but it will take a lot more time to come to that result. </p> <p>In any case, an example Levenshtein distance function for MySQL can be found at <a href="http://www.artfulsoftware.com/infotree/queries.php#552" rel="noreferrer">codejanitor.com: Levenshtein Distance as a MySQL Stored Function (Feb. 10th, 2007)</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload