MariaDB `SOUNDS LIKE`
In MariaDB, you can use SOUNDS LIKE
to compare whether two words are pronounced the same.
The SOUNDS LIKE
get the pronunciation of the word using SOUNDEX()
.
Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. If two words sound the same, they should have the same Soundex string. If two words sound similar but not identical, their Soundex strings may appear similar but not identical.
MariaDB SOUNDS LIKE
Syntax
The syntax is this:
expr1 SOUNDS LIKE expr2
This is the same as SOUNDEX(expr1) = SOUNDEX(expr2)
.
Parameters
expr1
-
Required. A word used to compare pronunciation.
expr2
-
Required. A word used to compare pronunciation.
Return value
MariaDB SOUNDS LIKE
is a logical comparison expression that returns 0
or 1
indicates whether two words have the same pronunciation.
If two words sound the same, they should have the same Soundex string, SOUNDS LIKE
expression returns 1
, otherwise returns 0
.
MariaDB SOUNDS LIKE
Examples
To compare whether Color
and Colour
pronounces the same, use the following statement:
SELECT 'Color' SOUNDS LIKE 'Colour';
Output:
+------------------------------+
| 'Color' SOUNDS LIKE 'Colour' |
+------------------------------+
| 1 |
+------------------------------+
You can use the SOUNDEX()
function to get their pronunciation codes, as follows:
SELECT
SOUNDEX('Color'),
SOUNDEX('Colour'),
SOUNDEX('Color') = SOUNDEX('Colour');
Output:
+------------------+-------------------+--------------------------------------+
| SOUNDEX('Color') | SOUNDEX('Colour') | SOUNDEX('Color') = SOUNDEX('Colour') |
+------------------+-------------------+--------------------------------------+
| C460 | C460 | 1 |
+------------------+-------------------+--------------------------------------+
In this example, the pronunciation codes for Color
and Colour
are both C460
.
Conclusion
MariaDB SOUNDS LIKE
is used to compare whether two words have the same pronunciation.