Substring_index function used in MySQL database

Substring_index function is used for substring the string before a specified number of delimiter occurs.

Syntax:

SUBSTRING_INDEX(string, delimiter, number)

string is the string
delimiter is the string which you want to remove from the string.
Number is the position of delimiter string which need to removed

Example:

SELECT SUBSTRING_INDEX("name@gmail.com", "@", 1);
Output:
--------
name

SELECT SUBSTRING_INDEX("rakesh@hotmail.com", ".", -1);
Output:
----------
com

This entry was posted in MySQL on by .
Unknown's avatar

About SandeepSingh

Hi, I am working in IT industry with having more than 15 year of experience, worked as an Oracle DBA with a Company and handling different databases like Oracle, SQL Server , DB2 etc Worked as a Development and Database Administrator.

Leave a Reply