SQL Tutorial SQL Advanced SQL Database SQL References

MySQL SOUNDS LIKE



The MySQL SOUNDS LIKE statement is used to compare the soundex string of two expressions. It is used as expr1 SOUNDS LIKE expr2, which is the same as SOUNDEX(expr1) = SOUNDEX(expr2).

Syntax

expr1 SOUNDS LIKE expr2

Parameters

expr1 Required. Specify the first expression which need to be compared.
expr2 Required. Specify the second expression which need to be compared.

Return Value

Compares the soundex string of two expressions and returns the result.

Example 1:

The example below shows the usage of SOUNDS LIKE statement:

mysql> SELECT 'Here' SOUNDS LIKE 'Heir';
Result: 1

mysql> SELECT 'Principal' SOUNDS LIKE 'Principle';
Result: 1

mysql> SELECT 'Anothers' SOUNDS LIKE 'Brothers';
Result: 0

mysql> SELECT 'There' SOUNDS LIKE 'Their';
Result: 1

mysql> SELECT 'Except' SOUNDS LIKE 'Accept';
Result: 0

mysql> SELECT 'Cache' SOUNDS LIKE 'Cash';
Result: 1

Example 2:

Consider a database table called Employee with the following records:

EmpIDFirstNameLastName
1JohnSmith
2MarryKnight
3JoWilliams
4KimSmythe
5RameshGupta
6HuangZhang

To select all the records from this table where LastName sounds like 'Smythe', the following query can be used:

SELECT * FROM Employee
WHERE LastName SOUNDS LIKE 'Smythe';

This will produce the result as shown below:

EmpIDFirstNameLastName
1JohnSmith
4KimSmythe

❮ MySQL Functions