Home  >  Article  >  Database  >  Oracle method to intercept the first digits of a string

Oracle method to intercept the first digits of a string

藏色散人
藏色散人Original
2020-04-21 09:36:4850045browse

Oracle method to intercept the first digits of a string

Oracle's method of intercepting the first few digits of a string

Oracle uses the substr function to advance the first few digits of a certain data .

For example, the data in the test table is as follows:

Oracle method to intercept the first digits of a string

Now to extract the first two digits in the dept field, you can use the following statement:

select id,name,substr(dept,1,2) from test;

Result:

Oracle method to intercept the first digits of a string

substr function introduction:

Syntax:

substr(string,start,length)

Parameters:

string - the specified one to be intercepted The string

start - required, specifies where to start in the string

Positive number - starts at the specified position in the string

Negative number - starts at the end of the string Starts at the specified position

0 - Starts at the first character in the string

length - Optional, specifies the length of the string to be intercepted, and returns the character expression by default All characters before the end of the value.

The above is the detailed content of Oracle method to intercept the first digits of a string. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn