Home >Database >Mysql Tutorial >What is the usage of substr function in database?

What is the usage of substr function in database?

coldplay.xixi
coldplay.xixiOriginal
2020-10-28 11:09:5580002browse

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字长的字符串。

So the result is: str

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

The result can only be: g

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

The result is: ing

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

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

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!

Statement:
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