Description
Returns an integer similarity score from 0 to 100 between two string values, where 100 is the strongest match and 0 is no similarity. Use it to filter rows by approximate match, deduplicate records with inconsistent spelling, or join on fields that do not match exactly. The function supports three comparison methods. Pick the one that fits the data:
Matching is case-sensitive for
levenshtein and jaro_winkler. Wrap the inputs in LOWER() for case-insensitive comparison. soundex is inherently case-insensitive.
Syntax
FUZZY_MATCH(string1, string2[, method])
Arguments
Examples
Keep rows whose company name is a close match forAcme Inc:
FUZZY_MATCH('Apple', 'Aple') returns 80.
FUZZY_MATCH('Apple', 'Apple') returns 100.
FUZZY_MATCH('Robert', 'Rupert', 'jaro_winkler') returns 85.
FUZZY_MATCH('Smith', 'Smyth', 'soundex') returns 100.
FUZZY_MATCH('Smith', 'Jones', 'soundex') returns 0.
FUZZY_MATCH(LOWER(name1), LOWER(name2)) performs a case-insensitive Levenshtein comparison.
Return value datatype
Integer (0–100).Notes
- The
levenshteinscore is the edit distance normalized by the longer string’s length, computed asround(100 * (1 - distance / maxLen)). soundexis designed for English and Latin-script letters. Accented characters such aséare normalized to their base form before encoding, so'José'matches'Jose'. Inputs in non-Latin scripts (such as Cyrillic or CJK) cannot be phonetically encoded and returnnull.- Identical inputs always score 100 for every method.
- The function raises an error if fewer than two arguments are supplied or if an unknown method is requested.
Impact of null value
Returnsnull if either string1 or string2 is null.