The SUBSTR function is used to intercept a portion of a column field in a database.
The names of the functions in each database are not the same (it is the egg pain, after the invention of the database can not be the same as the first invention?) )
Copy Code code as follows:
Mysql:substr (), SUBSTRING ()
Oracle:substr ()
SQL server:substring ();
The usual ways are:
Sbustr (Str,pos);
is the position from the beginning of the POS, has been intercepted to the last.
There is also a more commonly used:
Copy Code code as follows:
SUBSTR (Str,pos,len);
The meaning of this expression is to intercept Len characters (whitespace is also a character) from the point where the POS begins.
Note that if the POS is 1 (instead of 0), it means starting at the first position.
This also very good understanding, because the database is not our usual writing program, he has his own set of habits, the database records are starting from 1 did not start from 0. Right.