SOUNDS LIKE Function in MySQL
Last Updated :
14 Dec, 2020
SOUNDS LIKE :
This function in MySQL is used to compare the Soundex codes of a given two string expressions. It is used as SOUNDEX(expr1) = SOUNDEX(expr2) to retrieve strings that sound similar.
Syntax :
expr1 SOUNDS LIKE expr2
Parameter :
It accepts two parameter as mentioned above and described below.
- expr1 - The first string which we want to compare.
- expr2 -The second string which we want to compare.
Returns :
It compares the Soundex code of two string values and returns the output.
Example-1 :
Comparing similar two given string using SOUNDS LIKE Function.
SELECT 'geeks' SOUNDS LIKE 'geeks'
as Result;
Output :
Example-2 :
Comparing similar two given strings using SOUNDS LIKE Function.
SELECT 'geeks' SOUNDS LIKE 'for'
as Result;
Output :
Example-3 :
The following example shows returns all the rows which contain an Employee name whose first name sounds like 'Sayan'.
CREATE TABLE Employee
(
Employee_id INT AUTO_INCREMENT,
First_name VARCHAR(100) NOT NULL,
Last_name VARCHAR(100) NOT NULL,
Joining_Date DATE NOT NULL,
PRIMARY KEY(Employee_id )
);
Inserting some data to the Employee table :
INSERT INTO Employee
(First_name ,Last_name , Joining_Date )
VALUES
('Sayantan', 'Majumdar', '2000-01-11'),
('Anushka', 'Samanta', '2002-11-10' ),
('Sayan', 'Sharma', '2005-06-11' ),
('Shayari', 'Das', '2008-01-21' ),
('Sayani', 'Jain', '2008-02-01' ),
('Tapan', 'Samanta', '2010-01-11' ),
('Deepak', 'Sharma', '2014-12-01' ),
('Ankana', 'Jana', '2018-08-17'),
('Shreya', 'Ghosh', '2020-09-10') ;
So, the Employee Table is as follows.
select * from Employee ;
Output :
Employee_id | First_name | Last_name | Joining_Date |
---|
1 | Sayantan | Majumdar | 2000-01-11 |
2 | Anushka | Samanta | 2002-11-10 |
3 | Sayan | Sharma | 2005-06-11 |
4 | Shayari | Das | 2008-01-21 |
5 | Sayani | Jain | 2008-02-01 |
6 | Tapan | Samanta | 2010-01-11 |
7 | Deepak | Sharma | 2014-12-01 |
8 | Ankana | Jana | 2018-08-17 |
9 | Shreya | Ghosh | 2020-09-10 |
Now, we are going to check those employee whose first name sounds like 'sayan'.
SELECT * FROM Employee
WHERE First_name SOUNDS LIKE 'Sayan' ;
Output :
Employee_id | First_name | Last_name | Joining_Date |
---|
3 | Sayan | Sharma | 2005-06-11 |
5 | Sayani | Jain | 2008-02-01 |
Similar Reads
SOUNDEX() Function in MySQL
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 to compare words that are spelled differently, but sound alike in English. Syntax : SOUNDEX(str) Parameter : SOUNDEX() function accep
3 min read
ROUND() Function in MySQL
The ROUND() function in MySQL is used to round a number to a specified number of decimal places. If no specified number of decimal places is provided for round-off, it rounds off the number to the nearest integer. Syntax ROUND(X, D) Parameter Explanation This method accepts two parameters in the syn
2 min read
SECOND() Function in MySQL
SECOND() function in MySQL is used to return the second portion of a specified time or date-time value. The first parameter in this function will be the date/Date Time. This function returns the seconds from the given date value. The return value (seconds) will be in the range of 0 to 59. In this fu
2 min read
SUM() Function in MySQL
The SUM() function in MySQL is a powerful aggregate function used to calculate the total sum of values in a numeric column. By summing up the values in the specified column, this function helps in generating overall totals and performing calculations that provide meaningful insights from our data. I
4 min read
ORD() Function in MySQL
ORD() function in MySQL is used to find the code of the leftmost character in a string . If the leftmost character is not a multibyte character, it returns ASCII value. And if the leftmost character of the string str is a multibyte character, ORD returns the code for that character, calculated from
3 min read
LEFT() Function in MySQL
The LEFT() function in MySQL is used to extract a specified number of characters from the left side of a given string. It uses its second argument to decide, how many characters it should return. Syntax: LEFT (str, len)Parameter: This function accepts two parameters as mentioned above and described
1 min read
LN() Function in MySQL
LN() function : It is the function in MySQL is used to calculate the natural logarithm of a specific number with base e . The number must be greater than 0, otherwise it will return NULL. Syntax : LN(X) Parameter : LN() function accepts one parameter as mentioned above in the syntax and described be
2 min read
SIGN() Function in MySQL
SIGN() function in MySQL is used to return the sign of the given number. It returns 1 if the number is positive, -1 if the number is negative and 0 for zero. Syntax : SIGN(X) Parameter : SIGN() function accepts one parameter as input and will give you the results in values like Positive(+1),Negative
1 min read
SUBDATE() function in MySQL
SUBDATE() function in MySQL is used to subtracts a time value (as interval) from a given date. Syntax : SUBDATE(date, INTERVAL expr unit) Parameter : This function accepts three parameters as given below : date : First specified date. expr : The value of the time/date interval to subtract. unit : Th
2 min read
RAND() Function in MySQL
The RAND() function in MySQL is used to a return random floating-point value V in the range 0 <= V < 1.0. If we want to obtain a random integer R in the range i <= R < j, we have to use the expression : FLOOR(i + RAND() * (j â i)). Syntax : RAND(N) Parameter : This method accepts only on
3 min read