Return a substring before a delimiter. This function returns the substring from a string before a specified number of occurrences of a delimiter.
Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.
If any argument is NULL, returns NULL.
For example:
It means "Return all of the characters up to the 2nd occurrence of ."
- Returns the position of a string within a string
- Returns the position of a string within a string
- Returns a string based on position
This page is licensed: GPLv2, originally from
SUBSTRING_INDEX(str,delim,count)SUBSTRING_INDEX('www.mariadb.org', '.', 2)SELECT SUBSTRING_INDEX('www.mariadb.org', '.', 2);
+--------------------------------------------+
| SUBSTRING_INDEX('www.mariadb.org', '.', 2) |
+--------------------------------------------+
| www.mariadb |
+--------------------------------------------+
SELECT SUBSTRING_INDEX('www.mariadb.org', '.', -2);
+---------------------------------------------+
| SUBSTRING_INDEX('www.mariadb.org', '.', -2) |
+---------------------------------------------+
| mariadb.org |
+---------------------------------------------+