語法:

SUBSTRING_INDEX(欄位或字串, 分割符號, 計數);

SUBSTRING_INDEX(string, delimiter, count);

 

範例:

SELECT SUBSTRING_INDEX(‘www.rusnake.com’, ‘.’, 1);

www

SELECT SUBSTRING_INDEX(‘www.rusnake.com’, ‘.’, 2);

www.rusnake

SELECT SUBSTRING_INDEX(‘www.rusnake.com’, ‘.’, -1);

com

SELECT SUBSTRING_INDEX(‘www.rusnake.com’, ‘.’, -2);

rusnake.com