Home > Database > Mysql Tutorial > body text

What is the usage of substr function in database?

coldplay.xixi
Release: 2020-10-29 16:19:35
Original
79970 people have browsed it

Usage of the substr function in the database: 1. [SUBSTR(str,pos,len)] intercepts len characters from the position starting from pos; 2. [SUBSTR(str,pos)] starts from the position of pos, Cut to the end.

What is the usage of substr function in database?

Usage of substr function in database:

1, SUBSTR(str,pos,len): From the starting position of pos, intercept len ​​characters

substr(string ,1,3) :取string左边第1位置起,3字长的字符串。
Copy after login

So the result is: str

substr(string, -1,3):取string右边第1位置起,3字长的字符串。显然右边第一位置起往右不够3字长。
Copy after login

The result can only be: g

substr(string, -3,3):取string右边第3位置起,3字长的字符串。
Copy after login

The result is: ing

2, SUBSTR(str,pos): The starting position of pos, intercepted until the end

substr(string ,4) : 从右第4位置截取到最后
Copy after login

The result is: ing

More related free learning recommendations: mysql tutorial(Video)

The above is the detailed content of What is the usage of substr function in database?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template