What are the methods of string interception implemented by MySQL
This article mainly talks about "what are the methods of string interception in MySQL", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what are the methods of string interception in MySQL?"
Preface
It is common to deal with a database during back-end development, and sometimes there are two ways to deal with as long as part of a piece of data in the database:
(1) read it out and then deal with it accordingly
(2) use the function that comes with MySQL to process when reading.
Next, we will summarize the column in the second way.
(1) create a user table as follows:
(2) left (col_name, length) function: intercepted from left to right. Col_name is the column name (required), length is the length truncated from left to right (must be a positive integer, if negative, nothing is returned, the subscript starts at 1, not 0)
A:length: integer
B:length: negative number
(3) right (col_name, length) function: intercepted from right to left. Col_name is the column name (required), length is the length truncated from right to left (must be a positive integer, if negative, nothing is returned, starting with 1, not 0)
A:length: integer
B:length: negative number
(4) substring (col_name, start, length) function: col_name column name (required), start from which (integer must be selected from 1), length truncated length (optional, positive integer)
A:start: positive integer, length is not selected, count from left to right, and the third character is truncated to the right until the end.
B:start: negative integer, length is not selected, count from right to left, and the third character is truncated to the right until the end.
C:start: positive integer, length: positive integer; count from left to right, and the third character begins to truncate 5 characters to the right.
D:start: negative integer, length: positive integer; count from right to left, and the third character begins to truncate 3 characters to the right.
E: when intercepting from star, the number of characters immediately following it