Home >Database >Mysql Tutorial >What is the usage of substr function in database?
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.
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!