MySQL uses string Truncation in MySQL when creating a view today, which is very convenient. I feel that the string function of MySQL intercepts characters, which is more powerful than program interceptions (such as PHP or JAVA). So I want to make a record here and hope it will be useful to everyone. Function: www.2cto.com 1. Extract the string left (str, length) from the left. Description: left (truncated field, truncated length) Example: select left (content, 200) as abstract from my_content_t 2. Extract the string www.2cto.com right (str, length) from the right. Description: right (truncated field, truncated length) Example: select right (content, 200) as abstract from my_content_t 3. truncation string substring (str, pos) substring (str, pos, length) Description: substring (truncated field, starting from the nth digit) substring (truncated field, starting from the nth digit and intercepting the length) Example: select substring (content, 5) as abst Ract from my_content_t select substring (content, 5,200) as abstract from my_content_t (Note: if the number of digits is negative, for example,-5, it is the length from the last digit to the end or truncation of the string) 4. truncate the string substring_index (str, delim, count). Description: substring_index (truncated field, keyword, number of times the keyword appears). Example: select substring_index ("blog.cnblogs.com ",". ", 2) as abstract from my_content_t www.2cto.com result: blog. cnblogs (Note: if the number of times the keyword appears is negative, for example,-2, it is from the last to the end of the string) Result: cnblogs.com