Mysql string truncation command 1. substring_indexsubstring_index (str, delim, count)
[Html] www.2cto.com mysql> select substring_index ('A-B-c-d', '-',-1 ); + --------------------------------- + | substring_index ('A-B-c-d', '-',-1) | + rows + | d | + ------------------------------- + 1 row in set (0.00 sec) mysql> select substring_index ('A-B-c-d', '-', 1 ); + rows + | substring_index ('A-B-c-d', '-', 1) | + -------------------------------------- + | a | + rows + 1 row in set (0.00 sec) www.2cto.com 2. SUBSTRINGSUBSTRING (str, pos, len) SUBSTRING (str FROM pos FOR len) SUBSTRING (str, pos) SUBSTRING (str FROM pos)
[Html] mysql> select substring (substring_index ('A-B-c-d', '-', 2), 2 ); + --------------------------------------------- + | substring (substring_index ('A-B-c-d', '-', 2), 2) | + ----------------------------------------------- + |-B | + ----------------------------------------------- + 1 row in set (0.01 sec)