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:
EmpID | FirstName | LastName |
---|---|---|
1 | John | Smith |
2 | Marry | Knight |
3 | Jo | Williams |
4 | Kim | Smythe |
5 | Ramesh | Gupta |
6 | Huang | Zhang |
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:
EmpID | FirstName | LastName |
---|---|---|
1 | John | Smith |
4 | Kim | Smythe |
❮ MySQL Functions