Syntax\n------\n\nSUBSTRING_INDEX(str,delim,count)\n\nDescription\n-----------\n\nReturns 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_.\n\nIf any argument is NULL, returns NULL.\n\nFor example:\n\n``sql\nSUBSTRING_INDEX('www.mariadb.org', '.', 2)\n``\n\nIt means "Return all of the characters up to the 2nd occurrence of ."\n\nExamples\n--------\n\nSELECT SUBSTRING_INDEX('www.mariadb.org', '.', 2);\n+--------------------------------------------+\n| SUBSTRING_INDEX('www.mariadb.org', '.', 2) |\n+--------------------------------------------+\n| www.mariadb                                |\n+--------------------------------------------+\n\nSELECT SUBSTRING_INDEX('www.mariadb.org', '.', -2);\n+---------------------------------------------+\n| SUBSTRING_INDEX('www.mariadb.org', '.', -2) |\n+---------------------------------------------+\n| mariadb.org                                 |\n+---------------------------------------------+\n\nURL: https://mariadb.com/docs/server/reference/sql-functions/string-functions/substring_index