SQL's SUBSTR() function

The SUBSTR function is used to intercept a part of a column field in the database.

The function names in each database are different (it’s really painful, can’t the database invented later be the same as the one invented first?)

  • MySQL: SUBSTR( ), SUBSTRING( )
  • Oracle: SUBSTR( )
  • SQL Server: SUBSTRING( ) ;

Commonly used methods are:

SBUSTR(str,pos);
就是从pos开始的位置,一直截取到最后。

 

Another more common one is:

SUBSTR(str,pos,len);


This representation means that len ​​characters are intercepted from the position starting from pos (blanks are also counted as characters).

It should be noted that if pos is 1 (not 0), it means starting from the first position.

This is also easy to understand, because the database is not what we usually write programs, it has its own set of habits, and the records in the database start from 1 instead of 0. right.

 

Guess you like

Origin blog.csdn.net/howlaa/article/details/16825761