MariaDB SOUNDS LIKE Operator: Compare Strings by Sound
MariaDB’s SOUNDS LIKE operator compares two strings using their Soundex values. It is shorthand for comparing SOUNDEX(expr1) with SOUNDEX(expr2), so it can match different spellings that produce the same Soundex code.
SOUNDS LIKE does not return a pronunciation or measure how similar two strings are. It returns the result of an equality comparison between the Soundex strings. Different words can therefore match if their codes are equal, while similar-sounding words with different codes do not match. MariaDB’s SOUNDEX() implements the original Soundex algorithm and is intended to work well with English text; results for other languages may be unreasonable.
Syntax
expr1 SOUNDS LIKE expr2
This is equivalent to:
SOUNDEX(expr1) = SOUNDEX(expr2)
The comparison follows SQL’s usual equality rules. If an operand can be NULL, account for the possibility of an unknown (NULL) comparison result; see MariaDB’s = operator.
Compare spellings by Soundex value
This example compares two spellings that MariaDB encodes with the same Soundex value:
SELECT SOUNDEX('Color') AS color_code,
SOUNDEX('Colour') AS colour_code,
'Color' SOUNDS LIKE 'Colour' AS same_soundex;
+------------+-------------+--------------+
| color_code | colour_code | same_soundex |
+------------+-------------+--------------+
| C460 | C460 | 1 |
+------------+-------------+--------------+This is a code match, not proof that the database has measured pronunciation. To search a table, use the operator in a predicate:
SELECT givenname, surname
FROM users
WHERE givenname SOUNDS LIKE 'robert';
MariaDB’s documentation shows this query matching a row with givenname = 'Roberto'. Use ordinary equality when exact text matching is required, and use a dedicated fuzzy-matching approach when you need graded similarity or non-English phonetics.
Further reading
- MariaDB
SOUNDS LIKEreference - MariaDB
SOUNDEX()reference