C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
MySQL SUBSTRING_INDEX() FunctionThe substring_index() is a String function of MySQL. This function returns a substring from the given string(str) before the counts come of the delimiter. Syntax
select substring_index(str, delim, count); Parameter:
str: main string delim: string to be searched count: number of times to search delim Returns:
This function returns the substring of the string before a number of occurrences of delimiter. Example 1
Select substring_index('www.TheDeveloperBlog.com','.',3);
Output:
Example 2
Select substring_index('www.TheDeveloperBlog.com','.',2);
Output:
Example 3
Select substring_index('www.TheDeveloperBlog.com','.',1);
Output:
Example 4
Select substring_index('www.TheDeveloperBlog.com','.',-1);
Output:
Example 5
Select substring_index('www.TheDeveloperBlog.com','.',-2);
Output:
Next TopicMySQL String
|