Home >Database >Mysql Tutorial >MySQL interception and split string function usage example_MySQL
The example in this article describes the usage of MySQL interception and splitting string functions. Share it with everyone for your reference, the details are as follows:
First of all, the code is as follows:
SELECT SUBSTRING_INDEX(checkid,'-',-1) FROM `check` WHERE checkid = 'c-11065-50'
The code is as follows:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(checkid,'-',-2),'-',1) FROM check WHERE checkid = 'c-11065-50'
The code is as follows:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(checkid,'-',2),'-',-1) FROM check WHERE checkid = 'c-11065-50'
The following is the combined usage. For example, we want to intercept 13 in content_13-11220-1. The simplest one is:
The code is as follows:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(SUBSTRING(commentid,9), '-', 1), '-',-1) FROM check WHERE commentid = 'content_13-11220-1'
The code is as follows:
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(commentid, '-', 1), '_',-1) FROM check WHERE commentid = 'content_13-11220-1'
For more MySQL functions, please refer to the MySQL function encyclopedia: http://www.bitsCN.com/article/42906.htm
Readers who are interested in more MySQL-related content can check out the special topics of this site: "A Summary of Commonly Used MySQL Functions", "A Complete Collection of MySQL Log Operation Skills", "A Summary of MySQL Transaction Operation Skills", "A Complete Collection of MySQL Stored Procedure Skills" and " Summary of MySQL database lock related skills》
I hope this article will be helpful to everyone’s MySQL database planning.