SQL SUBSTR () function usage

Source: Internet
Author: User

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.

Related Article

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.