MySQL Function Reference

SUBSTRING_INDEX
Returns the substring from string before count occurrences of the delimiter.
MySQL 8.1
SUBSTRING_INDEX(string, delimiter, count)
string
The source string.
delimiter
The delimiter to search for.
count
The number of occurrences of the delimiter.
Examples
MySQL 8.1
SELECT SUBSTRING_INDEX('www.mysql.com', '.', 2)