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