Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

mysql substr() function


May 16, 2021 MySQL


Table of contents


mysql substr() function

Intercept the string


Usage: substr (string string, num start, num length);

Select substr (parameter 1, argument 2, parameter 3) from the table name


String is a string, start is the starting position, and length is length.

Note: Starts with 1 in mysql.

Example: (Find out the first time in the kename field.) previous string)

select kename,substr(kename,1,locate('.',kename)) as subkename from  web_dev_api where 1;

mysql substr() function


Intercept the first two characters

mysql substr() function