sql中charindex的使用

在sql中charindex是查找前字符串在后字符串中的位置

select charindex('56','123456') 

最终返回的结果是5,若不存在,则返回 0

 

=====================================================================

在oracle中是没有这个函数的,但是有相对应的函数instr

instr()函数是返回后一个字符串在前一个字符串的位置,若不存在,则返回 0

select instr('12345','2') from dual

最终返回的结果为 2

posted @ 2021-01-07 22:57  masha2017  阅读(1081)  评论(0编辑  收藏  举报