Introduction to SQL Substr () function _mssql

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.