The following articles mainly describe the basic function type of the MySQL database stored procedure, that is, the string, which is often used in actual operations, the following articles mainly describe the timing application and related functions of MySQL strings.
String type
CHARSET (str) // returns the string Character Set
CONCAT (string2 [,...]) // connection string
INSTR (string, substring) // returns the position of the first occurrence of the substring in the string. If no position exists, 0 is returned.
LCASE (string2) // converts it to lowercase
LEFT (string2, length) // take the length from the LEFT of string2
LENGTH (string) // string LENGTH
LOAD_FILE (file_name) // read content from the file
LOCATE (substring, string [, start_position]) is the same as INSTR, but the start position can be specified.
LPAD (string2, length, pad) // repeat pad to start with string until the string length is length
LTRIM (string2) // remove leading Spaces
REPEAT (string2, count) // REPEAT count times
REPLACE (str, search_str, replace_str) // REPLACE search_str with replace_str in str
RPAD (string2, length, pad) // use pad after str until the length is length.
RTRIM (string2) // remove backend Spaces
STRCMP (string1, string2) // compare the size of two strings by character,
SUBSTRING (str, position [, length]) // starts from the position of str and takes length characters,
Note: When the MySQL database processes strings, the default subscript of the first character is 1, that is, the parameter position must be greater than or equal to 1.
- MySQL> select substring('abcd',0,2);
- +-----------------------+
- | substring('abcd',0,2) |
- +-----------------------+
- | |
- +-----------------------+
- 1 row in set (0.00 sec)
- MySQL> select substring('abcd',1,2);
- +-----------------------+
- | substring('abcd',1,2) |
- +-----------------------+
- | ab |
- +-----------------------+
- 1 row in set (0.02 sec)
- TRIM([[BOTH|LEADING|TRAILING] [padding] FROM]string2)
Removes specified characters from a specified position.
UCASE (string2) // converts to uppercase
RIGHT (string2, length) // gets the last length character of string2
SPACE (count) // generate count Spaces
The above content is an introduction to the strings in the basic functions of the MySQL database stored procedure. I hope you will have some gains.