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

Oracle method to intercept the first digits of a string

藏色散人
Release: 2020-04-27 16:37:29
Original
50225 people have browsed it

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;
Copy after login

Result:

Oracle method to intercept the first digits of a string

substr function introduction:

Syntax:

substr(string,start,length)
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template