MySQL8 SOUNDS LIKE() Functions – String Functions

SOUNDS LIKE() Functions returns value 0 (False)or 1(True) depending upon the sounds of the input strings matches or not.

This operator works best on strings in the English language (using it with other languages may return unreliable results).

Returns NULL if any of the argument is NULL.


MySQL SOUNDS LIKE Functions: Syntax

expression1 SOUNDS LIKE expression2;
Above syntax can also be rewitten as
SOUNDEX(expression1)  =  SOUNDEX(expression2)

MySQL SOUNDS LIKE Functions: Parameter

[table caption=”” width=”100%” colwidth=”15%|15%|15%|55%” colalign=”left|left|left|left”]
Name, Required /Optional,Type, Description
expression1 , Required, String , It represents valid string.
expression2, Required, String , It represents valid string.
[/table]


MySQL SOUNDS LIKE Functions: Output

[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Return, Description
NULL, if argument is NULL.
0, if the input strings don’t sound similar
1, if the input strings sound similar
[/table]


MySQL SOUNDS LIKE Functions: Available from

[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 5.7
[/table]


SOUNDS LIKE Example 1 : Very easy example

We have to pass our string in the input parameter and we will get the sound string value of the inputs. Below is the example to show if the sound of both the words is similar then it returns 1.

mysql> SELECT 'male' SOUNDS LIKE 'mail';
+---------------------------+
| 'male' SOUNDS LIKE 'mail' |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.05 sec)

SOUNDS LIKE Example 2 : Some more examples

Below are some more examples.

Smysql> SELECT 'ball' SOUNDS LIKE 'bawl';
+---------------------------+
| 'ball' SOUNDS LIKE 'bawl' |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT 'made' SOUNDS LIKE 'maid';
+---------------------------+
| 'made' SOUNDS LIKE 'maid' |
+---------------------------+
|                         1 |
+---------------------------+
1 row in set (0.00 sec)
mysql> SELECT 'arc' SOUNDS LIKE 'ark';
+-------------------------+
| 'arc' SOUNDS LIKE 'ark' |
+-------------------------+
|                       1 |
+-------------------------+
1 row in set (0.00 sec)

Above example returns the 1 value as all input string sound is similar.


SOUNDS LIKE Example 3 : Compared to SOUNDEX function

Here it is compared to SOUNDEX(). See below example :

mysql> SELECT 'made' SOUNDS LIKE 'maid' AS 'SOUNDS LIKE', 
              SOUNDEX('made') = SOUNDEX('maid') AS 'SOUNDEX()';
+-------------+-----------+
| SOUNDS LIKE | SOUNDEX() |
+-------------+-----------+
|           1 |         1 |
+-------------+-----------+
1 row in set (0.25 sec)

SOUNDS LIKE Example 4 : NULL arguments

If any of the arguments is NULL, it will return NULL. See below example :

mysql> SELECT 'made' SOUNDS LIKE NULL;
+-------------------------+
| 'made' SOUNDS LIKE NULL |
+-------------------------+
|                    NULL |
+-------------------------+
1 row in set (0.06 sec)

mysql> SELECT NULL SOUNDS LIKE 'maid';
+-------------------------+
| NULL SOUNDS LIKE 'maid' |
+-------------------------+
|                    NULL |
+-------------------------+
1 row in set (0.00 sec)

See all MySQL String functions MySQL 8 String Functions.


Related articles : LOCATE(), HEX(), CONCAT(), CONCAT_WS() , LOWER(), LTRIM(), INSTR(), POSITION().


PHP Related articles : METAPHONE(), SOUNDEX(), PHP STRING FUNCTIONS(), SUBSTR_REPLACE().

You may also like...