1. left(name,4) intercepts the 4 characters on the left List: Results: 2018 2. right (name, 2) intercepts the 2 characters on the right Result: 09 3. SUBSTRING(name,5,3) intercepts the name field starting from the fifth character and only intercepts the next 3 characters Results: Division 4. SUBSTRING(name,3) intercepts the name field starting from the third character and all subsequent characters Results: Financing Division 5. SUBSTRING(name, -4) starts from the 4th character position (counting down) of the name field and continues until the end Result: Investment Division 6. SUBSTRING(name, -4, 2) starts from the 4th character position (countdown) of the name field and only takes the next 2 characters. Results: Note: We noticed that in the function substring(str,pos,len), pos can be negative, but len cannot be negative. 7. substring_index('www.baidu.com', '.', 2) intercepts all characters before the second '.' Results: www.baidu 8. substring_index('www.baidu.com', '.', -2) intercepts all characters after the second '.' (counting down) Result: baidu.com 9. SUBSTR(name, 1, CHAR_LENGTH(name)-3) intercepts the name field and removes all characters except the last three digits of the name field Result: Chengdu Financing Summarize The above is the MySQL SQL statement for intercepting string functions introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: Ubuntu 16.04 installation tutorial under VMware 12
>>: How to write elegant JS code
In order to download this database, it takes a lo...
Preface Recently, due to work reasons, I was work...
Table of contents What is MVCC MVCC Implementatio...
Install mysql5.7.18 on CentOS6.7 1. Unzip to the ...
Table of contents Configure node.js+nvm+npm npm s...
I have always wanted to learn about caching. Afte...
MySQL is divided into installation version and fr...
Table of contents 1. What is nginx? 2. What can n...
Table of contents Preface analyze Data Total Repe...
usemap is an attribute of the <img> tag, use...
Table of contents Preface Architecture at a Glanc...
20200804Addendum: The article may be incorrect. Y...
Table of contents Overview (Loop Mode - Common) D...
Table of contents Preparation Deployment process ...
The default time type (datetime and timestamp) in...