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
The vue mobile terminal determines the direction ...
MySQL 5.7.17, now seems to be the latest version,...
Preface When backing up the database, a full data...
1. Command Introduction The file command is used ...
Table of contents 1. Table self-sorting 2. Paging...
1. unlink function For hard links, unlink is used...
1. Oracle is a large database while MySQL is a sm...
background Flex layout achieves alignment and spa...
Tip: The following operations are all performed u...
Table of contents Introduction Step 1 Step 2: Cre...
Recently, new projects have used springcloud and ...
Table of contents 1. Build local storage 2. Creat...
This article describes the MySQL user rights mana...
Table of contents 1 Indicators in stress testing ...
This article records the installation graphic tut...