The SUBSTR function is used to intercept a part of a column of fields in the database.
The function names in different databases are different (it's really a headache, isn't the database invented later the same as the one first invented ?)
Copy codeThe Code is as follows:
MySQL: SUBSTR (), SUBSTRING ()
Oracle: SUBSTR ()
SQL Server: SUBSTRING ();
Common methods are:
SBUSTR (str, pos );
It is the position starting from the pos, Which is intercepted until the end.
Another common method is:
Copy codeThe Code is as follows:
SUBSTR (str, pos, len );
This indicates the position starting from the pos, intercepting len characters (white space is also a character ).
Note that if pos is 1 (instead of 0), it indicates that the position starts from the first position.
This is also easy to understand, because the database is not a program we usually write, he has his own set of habits, the database records are from 1 does not start from 0. Right.