function substring:
1. Intercept string from left
Left (str, length)
Description: Left (truncated field, intercept length)
Example: Select Left (content,200) as abstract from my_content_t
2, starting from the right to intercept the string
Right (str, length)
Description: Right (truncated field, intercept length)
Example: Select Right (content,200) as abstract from my_content_t
3. Intercepting strings
SUBSTRING (str, POS)
SUBSTRING (str, pos, length)
Description: Substring (intercepted field, starting from the first intercept)
SUBSTRING (intercepted field, starting from the first intercept, intercept length)
Example: Select substring (content,5) as abstract from my_content_t
Select substring (content,5,200) as abstract from my_content_t
(Note: If the number of digits is negative, 5 is the number of digits from the back to the end of the string or the length of the Intercept)
4. Intercept strings by keyword
Substring_index (Str,delim,count)
Description: Substring_index (the number of occurrences of the intercepted field, keywords, keywords)
Example: Select Substring_index ("Blog.jb51.net", ". ", 2) as abstract from my_content_t
Results: blog.jb51
(Note: If the number of occurrences of a keyword is negative, 2 is the inverse from the back to the end of the string)
Introduction to Functions:
SUBSTRING (str,pos), SUBSTRING (str from pos) SUBSTRING (str,POS ,len), SUBSTRING (str from pos for len)
The format without the len parameter returns a substring from the string str , starting at position Pos. The format with the len parameter returns a substring of the same length as the Len character from the string str , starting at position Pos. Use the from format as standard SQL syntax. You may also use a negative value for the POS . If so, the position of the substring starts at the POS character at the end of the string, not at the beginning of the string. You can use a negative value for the POS in the following format function.
function ASCII:
ASCII (str)
The leftmost string is the value returned by Str. If Str is an empty string, return 0. Returns null if STR is NULL. ASCII () characters from 0 to 255 of numeric values.
Mysql> SELECT ASCII ('2');+---------------------------------------------------------+| ASCII ('2') |+---------------------------------------------------------+| -|+---------------------------------------------------------+1Rowinch Set(0.00sec) MySQL> SELECT ASCII ('DX');+---------------------------------------------------------+| ASCII ('DX') |+---------------------------------------------------------+| -|+---------------------------------------------------------+1Rowinch Set(0.00Sec
MySQL string intercept function substring and ASCII () function