Home > Database > Mysql Tutorial > body text

Oracle中INSTR,SUBSTR方法

WBOY
Release: 2016-06-07 16:55:45
Original
947 people have browsed it

INSTR方法的格式为 INSTR(源字符串, 目标字符串, 起始位置, 匹配序号) 例如:INSTR(

INSTR方法的格式为
INSTR(源字符串, 目标字符串, 起始位置, 匹配序号)

例如:INSTR('CORPORATE FLOOR','OR', 3, 2)中,,源字符串为'CORPORATE FLOOR', 目标字符串为'OR',起始位置为3,取第2个匹配项的位置。

默认查找顺序为从左到右。当起始位置为负数的时候,从右边开始查找。

所以SELECT INSTR('CORPORATE FLOOR', 'OR', -1, 1) "Instring" FROM DUAL的显示结果是

Instring
——————
14


Oracle的substr函数的用法
取得字符串中指定起始位置和长度的字符串   substr( string, start_position, [ length ] )
如:
     substr('This is a test', 6, 2)     would return 'is'
     substr('This is a test', 6)     would return 'is a test'
     substr('TechOnTheNet', -3, 3)     would return 'Net'
     substr('TechOnTheNet', -6, 3)     would return 'The'select substr('Thisisatest', -4, 2) value from dual

linux

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