Home  >  Article  >  Database  >  SQL中Charindex和Oracle中对应的函数Instr

SQL中Charindex和Oracle中对应的函数Instr

WBOY
WBOYOriginal
2016-06-07 15:44:321157browse

在项目中用到了Oracle中 Instr 这个函数,顺便仔细的再次学习了一下这个知识。 Oracle中,可以使用 Instr 函数对某个字符串进行判断,判断其是否含有指定的字符。 其语法为: Instr(string, substring, position, occurrence) 其中 string:代表源字符串; s

在项目中用到了Oracle中 Instr 这个函数,顺便仔细的再次学习了一下这个知识。

Oracle中,可以使用 Instr 函数对某个字符串进行判断,判断其是否含有指定的字符。

其语法为:
Instr(string, substring, position, occurrence)
其中

string:代表源字符串;

substring:代表想聪源字符串中查找的子串;

position:代表查找的开始位置,该参数可选的,默认为 1;

occurrence:代表想从源字符中查找出第几次出现的substring,该参数也是可选的,默认为1;
如果 position 的值为负数,那么代表从右往左进行查找。
返回值为:查找到的字符串的位置。

对于 Instr 函数,我们经常这样使用:从一个字符串中查找指定子串的位置。

例如:

SELECT Instr('Hello Word', 'o', -1, 1) "String" FROM Dual 的显示结果是

Instring
————
8

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