Home > Database > Mysql Tutorial > Oracle中判断一个串中是否包含另一个串

Oracle中判断一个串中是否包含另一个串

WBOY
Release: 2016-06-07 16:57:47
Original
1317 people have browsed it

Sql代码 select decode(INSTR(

Sql代码

select decode(INSTR('CORPORATEaaaa FLOOR', 'aaaa'),0,0,1) FROM DUAL

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

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