Thursday, April 28, 2011

MySQL Soundex Example

mysql tutorial
Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. The goal is for homophones to be encoded to the same representation so that they can be matched despite minor differences in spelling. The algorithm mainly encodes consonants; a vowel will not be encoded unless it is the first letter. Soundex is the most widely known of all phonetic algorithms, as it is a standard feature of MS SQL and Oracle, and is often used (incorrectly) as a synonym for "phonetic algorithm". Improvements to Soundex are the basis for many modern phonetic algorithms.

Soundexis a phonetic normalization function that was invented for the 1880 U.S. Censusto get around the problem of sorting information by last names with different spellings but similar or identical sounds, such as Smith and Smythe. Since then, it's become one of the more popular ways of searching for similar sounding names in genealogy and government applications.

In this tutorial we will use the MySQL SOUNDEX() function, it will very help for searching purpose i.e. if a user search for something and he/she spell wrong then we can use SOUNDEX() to understand the search term.

Method Signature for SOUNDEX

String SOUNDEX(String)

Example 1

SELECT SOUNDEX('tutorialjinni');
it will yeild T6425

comparing two words that sound same
SELECT STRCMP(SOUNDEX('sun'), SOUNDEX('son')) AS Result;
Output is 0 because both words sound same and for that reason there SOUNDEX() codes are same, for reference SOUNDEX code for both sun and son is S500

Limitations

  • This function, as currently implemented, is intended to work well with strings that are in the English language only. Strings in other languages may not produce reliable results.
  • This function is not guaranteed to provide consistent results with strings that use multi-byte character sets, including utf-8.

0 comments:

Post a Comment

 

Blog Info

A Pakistani Website by Originative Systems

Total Pageviews

Tutorial Jinni Copyright © 2015 WoodMag is Modified by Originative Systems