SOUNDEX_MATCHES

Compares the Soundex encodings of two strings.

Compares the Soundex encodings of two strings. The function then returns an integer that indicates the number of matching characters, in the same order. The return value is 0 to 4 inclusive, where 0 indicates no match, and 4 an exact match.

For details on how Vertica implements Soundex encoding, see Soundex Encoding Algorithm.

Behavior type

Immutable

Syntax

SOUNDEX_MATCHES ( string-expression1, string-expression2 )

Arguments

string-expression1, string-expression2
The two VARCHAR expressions to encode and compare.

Examples

Find how well the Soundex encodings of two strings match:

  • Compare the Soundex encodings of Lewis and Li:

    > SELECT SOUNDEX_MATCHES('Lewis', 'Li');
     SOUNDEX_MATCHES
    -----------------
                   3
    (1 row)
    
  • Compare the Soundex encodings of Lee and Li:

    => SELECT SOUNDEX_MATCHES('Lee', 'Li');
     SOUNDEX_MATCHES
    -----------------
                   4
    (1 row)
    

Find last names in the employee_dimension table whose Soundex encodings match at least 3 characters in the encoding for Lewis:

=> SELECT DISTINCT(employee_last_name)
      FROM public.employee_dimension
      WHERE SOUNDEX_MATCHES (employee_last_name, 'Lewis' ) >= 3 ORDER BY employee_last_name;
 employee_last_name
--------------------
 Lea
 Lee
 Leigh
 Lewis
 Li
 Reyes
(6 rows)

See also

SOUNDEX