MySQL Tutorial

MySQL Tutorial MySQL Features MySQL Database Introduction MySQL Environmental Setup MySQL Data Types MySQL variable MySQL Advance table Query MySQL database queries MySQL Entity-Relationship Model MySQL Table Query MySQL Operators MySQL logical conditions MySQL Queries MySQL Clauses Clustered vs Non-Clustered Index MySQL Full text index MySQL Descending Index MySQL Invisible Index MySQL Composite Index MySQL Prefix index MySQL Index MySQL Create index MySQL Drop Index MySQL Show index MySQL Unique index MySQL Table MySQL Variable MySQL View MySQL Constraints MySQL Command Line Client Basic Queries MySQL Stored Procedure MySQL IF Statement MySQL Subquery MySQL Triggers

MySQL Join

MySQL Join MySQL CROSS JOIN MySQL DELETE JOIN MySQL EQUI JOIN MySQL INNER JOIN MySQL Union MySQL NATURAL JOIN MySQL RIGHT JOIN MySQL SELF JOIN MySQL UPDATE JOIN

MySQL Function

MySQL Function MySQL AVG() Function MySQL SUM() Function MySQL String() Function MySQL Advance() Function MySQL Aggregate() Function MySQL COALESCE() Function MySQL Control Flow Function MySQL COUNT() Function MySQL Date And Time Function MySQL GREATEST() Function MySQL ISNULL() Function MySQL LEAST() Function MySQL Math() Function MySQL MAX() Function MySQL MIN() Function MySQL find_in_set() function MySQL ASIN() Function MySQL CEIL() function MySQL CEILING() function MySQL TAN() Function MySQL Truncate() Function MySQL FLOOR() function MySQL LN() function MySQL LOG2() function MySQL LOG10() function MySQL MOD() function MySQL PI() function MySQL POW() function MySQL RADIANS() function MySQL RAND() function MySQL ROUND() function MySQL Character Length Function MySQL Current Date Function MySQL Date Add Function MySQL Date Format Function MySQL Datediff Function MySQL Day Function MySQL Elt Function MySQL Export Set Function MySQL Field Function MySQL Format Function MySQL From Base64 Function MySQL Hex Function MySQL Insert Function MySQL Instr Function MySQL Length Function MySQL CONCAT() function MySQL FIND_IN_SET() function MySQL LIKE() function MySQL LOAD_FILE() function MySQL LOCATE() function MySQL LOG() function MySQL MONTHNAME() function MySQL NOW() function MySQL PERIOD_ADD() function MySQL PERIOD_DIFF() function MySQL POWER() function MySQL QUARTER() function MySQL REVERSE() function MySQL RIGHT() Function MySQL RPAD() function MySQL RTRIM() function MySQL SEC_TO_TIME() function MySQL SOUNDEX() function

Questions

Which Clause is Similar to Having Clause in MySQL

Misc

MySQL Error 1046 - No Database Selected Failed to Start MySQL Service Unit MySQL Service Unit not Found Import MySQL Connector Mudule not Found Error No Module Named MySQL Joins Available in MySQL MySQL Docs MySQL Download For Windows 7 64 Bit MySQL Error Code 1064 MySQL Export MySQL History MySQL Host MySQL Import MySQL Drop All Tables MySQL Drop MySQL Error Code 1175 MySQL Events MySQL Except MYSQL Foreign Key Constraint MySQL If Exists MySQL IndexOf MySQL List All Tables json_extract in MySQL TIMESTAMPDIFF in MySQL MySQL Syntax Checker Sudo MySQL Secure Installation

MySQL SOUNDEX() function

In this context, we will learn how we can use the MySQL SOUNDEX() function with proper syntax and good examples.

Introduction of MySQL SOUNDEX() function

SOUNDEX() function in MySQL is used to return a phonetic representation of a string. The phonetic represents the way the string will sound. The SOUNDEX function helps compare words spelled differently but sound alike in English.

Syntax of the MySQL SOUNDEX() function

The syntax of the MySQL SOUNDEX() function is given as follows:

SOUNDEX(str)

Parameters or arguments used in MySQL SOUNDEX() function:

Only one parameter is accepted by the SOUNDEX() function in MySQL, which is given as mentioned above and described below.

Str: The string whose phonetic representation we want to know.

Returns:

It will return a phonetic representation of the given string.

Some important points of MySQL SOUNDEX function:

This function, as currently implemented, is intended to work well with strings that are in the English language only. Strings in other languages may not produce reliable results.

This function is not guaranteed to provide consistent results with strings that use multibyte character sets, including utf-8.

Application used for SOUNDEX() function:

The SOUNDEX() function can be used in the given below MySQL versions.:

  • MySQL 5.7
  • MySQL 5.6
  • MySQL 5.5
  • MySQL 5.1
  • MySQL 5.0
  • MySQL 4.1
  • MySQL 4.0
  • MySQL 3.23

Examples of MySQL SOUNDEX() function:

Now we will look into some MySQL SOUNDEX() function examples and will explore how we can use the SOUNDEX function in MySQL.

Example 1:

In this example, we will Find the SOUNDEX string of 'JAVATPOINT' using the SOUNDEX Function in MySQL.

SELECT SOUNDEX(' JAVATPOINT ') AS SoundexString;

Output:

SoundexString
J131
1 row in set (0.00 sec)

Example 2:

In this example, we will Find the SOUNDEX string of 'WORLD' using the SOUNDEX Function in MySQL.

SELECT SOUNDEX('WORLD') AS SoundexString;

Output:

SoundexString
W643
1 row in set (0.00 sec)

Example 3:

When we require to find the SOUNDEX string for column data, then we can take the help of the SOUNDEX function in MySQL. For demonstration, we have created a table named Pupil.

CREATE TABLE Pupil(
Pupil_id INT AUTO_INCREMENT,
Pupil_name VARCHAR(100) NOT NULL,
Pupil_Class VARCHAR(20) NOT NULL,
PRIMARY KEY(Pupil_id )
);

Now we will insert some data into the Pupil table :

INSERT INTO Pupil
(Pupil_name, Pupil_Class )
VALUES
('Ananya Majumdar', 'IX'),
('Anushka Samanta,' 'X'),
('Aniket Sharma', 'XI' ),
('Anik Das,' 'X'),
('Riya Jain,' 'IX'),
('Tapan Samanta', 'X' ),
('Deepak Sharma,' 'X'),
('Ankana Jana', 'XII'),
('Shreya Ghosh,' 'X') ;

So, the Pupil Table is as follows.

mysql> select * from Pupil;
Pupil_idPupil_namePupil_Class
1Ananya MajumdarIX
2Anushka SamantaX
3Aniket SharmaXI
4Anik DasX
5Riya JainIX
6Tapan SamantaX
7Deepak SharmaX
8Ankana JanaXII
9Shreya GhoshX

Now, we are going to find the SOUNDEX string for column Pupil_name.

SELECT
Pupil_id, Pupil_name,
SOUNDEX( Pupil_name) AS SoundexSname,
Pupil_Class FROM Pupil ;

Output:

Pupil_idPupil_nameSoundexSnamePupil_Class
1Ananya MajumdarA52536IX
2Anushka SamantaA5253X
3Aniket SharmaA523265XI
4Anik DasA5232X
5Riya JainR250IX
6Tapan SamantaT15253X
7Deepak SharmaD1265X
8Ankana JanaA52525XII
9Shreya GhoshS620X

9 rows in set (0.00 sec)

Application of MySQL SOUNDEX() function:

This function is used to return a phonetic representation of a string.

Summary:

In the above context, we have learned how we can use the SOUNDEX() function in MySQL used to return a phonetic representation of a string.