w3resource
MYSQL Tutorial

MySQL SOUNDS LIKE

SOUNDS LIKE

MySQL SOUNDS LIKE is used as SOUNDEX(expr) = SOUNDEX(expr) to retrieve strings sounds similar.

Soundex is a phonetic algorithm for indexing names after English pronunciation of sound.

Syntax:

expr1 SOUNDS LIKE expr2

MySQL Version: 5.6

Video Presentation

Argument

Name Description
str A string.

Example: MySQL SOUNDS LIKE

The following MySQL statement returns all the rows which contain a student name which sounds like 'sudipto'. It returns two rows.

Code:

SELECT * FROM student 
WHERE first_name SOUNDS LIKE 'sudipto' ;

Sample table: student

mysql> select * from student;
+------+------------+-----------+-------+------------+
| id   | first_name | last_name | marks | city       |
+------+------------+-----------+-------+------------+
|    1 | Sudipto    | Sen       |    93 | Kolkata    | 
|    2 | Amit       | Singh     |    94 | Chandigarh | 
|    3 | Asif       | Khan      |    91 | Mumbai     | 
|    4 | Vasant     | Natarajan |    90 | Channai    | 
|    5 | Amar       | Sharma    |    91 | Lucknow    | 
|    6 | Sudipta    | Roy       |    92 | Delhi      | 
|    7 | Anand      | Rao       |    88 | Bangalore  | 
|    8 | Rahul      | Gupta     |    93 | Jaipur     | 
+------+------------+-----------+-------+------------+
8 rows in set (0.00 sec)

Sample Output:

mysql> SELECT * FROM student
    -> WHERE first_name SOUNDS LIKE 'sudipto' ;
+------+------------+-----------+-------+---------+
| id   | first_name | last_name | marks | city    |
+------+------------+-----------+-------+---------+
|    1 | Sudipto    | Sen       |    93 | Kolkata | 
|    6 | Sudipta    | Roy       |    92 | Delhi   | 
+------+------------+-----------+-------+---------+
2 rows in set (0.00 sec)

All String Functions

MySQL String Functions, slide presentation


ankara escort