SUBSTRING_INDEX() function in MySQL Last Updated : 23 Sep, 2020 Comments Improve Suggest changes Like Article Like Report SUBSTRING_INDEX() function in MySQL is used to return a substring from a string before a specified number of occurrences of the delimiter. Syntax : SUBSTRING_INDEX( str, delim, count ) Parameter : This method accepts three-parameter as mentioned above and described below : str : The original string from which we want to create a substring. delim : Is a string that acts as a delimiter. The function performs a case-sensitive match when searching for the delimiter. count : It identifies the number of times to search for the delimiter. It can be both a positive or negative number. If it is a positive number, this function returns all to the left of the delimiter. If it is a negative number, this function returns all to the right of the delimiter. Returns : It returns substring from a given string. Example-1 : SUBSTRING_INDEX() function with a positive number of occurrences of a delimiter SELECT SUBSTRING_INDEX("www.geeksforgeeks.org", ".", 2) as Sub_Str; Output : Sub_Str www.geeksforgeeks Example-2 : SUBSTRING_INDEX() function with a negative number of occurrences of a delimiter. SELECT SUBSTRING_INDEX("www.geeksforgeeks.org", ".", -2) as Sub_Str; Output : Sub_Str geeksforgeeks.org Example-3 : SUBSTRING_INDEX() function with the table data. Table : Employee : Employee_Id Address 101 700000 Kolkata W.B 102 735102 Jalpaiguri W.B 103 721101 Midnapore W.B 104 734001 Siliguri W.B Now, we will find the pin number address of every employee by using SUBSTRING_INDEX function. SELECT SUBSTRING_INDEX(Address, ' ', 1 ) AS Pin_Num FROM Employee Output : Pin_Num 700000 735102 721101 734001 Comment More infoAdvertise with us Next Article SUBSTRING_INDEX() function in MySQL J jana_sayantan Follow Improve Article Tags : SQL DBMS-SQL mysql Similar Reads SUBSTRING() function in MySQL SUBSTRING() : function in MySQL is used to derive substring from any given string .It extracts a string with a specified length, starting from a given location in an input string. The purpose of substring is to return a specific portion of the string. Syntax : SUBSTRING(string, start, length) OR SUB 2 min read SQL Server SUBSTRING() Function The SQL Server SUBSTRING function extracts a substring from a string, starting at a specified position and with an optional length. The SUBSTRING function also works in Azure SQL Database, Azure SQL Data Warehouse, and Parallel Data Warehouse. SyntaxThe SQL SUBSTRING function syntax is: SUBSTRING(in 3 min read SOUNDS LIKE Function in MySQL 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 be 2 min read TRIM() Function in MySQL TRIM() function in MySQL is used to clean up data. It is also used to remove the unwanted leading and trailing characters in a string. Syntax : TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) Parameter : This method accepts three-parameter as mentioned above and described below : BOTH | LEADIN 2 min read POSITION() function in MySQL POSITION() : This function in MySQL is used for finding the location of a substring in a string. It will return the location of the first occurrence of the substring in the string. If the substring is not present in the string then it will return 0. When searching for the location of a substring in 2 min read Like