sql 计算字符从后向前出现的位置,用两个函数,instr,reverse(空格也算一位)
INSTR方法的格式为
INSTR(源字符串, 目标字符串, 起始位置, 匹配序号)
默认查找顺序为从左到右。当起始位置为负数的时候,从右边开始查找。但是下标值还是从前向后的只是如果字符偏后效率快些
如
sql>select instr(‘abcdefg’,’b’,-1,1) from dual;
—
2
REVERSE字符串反转函数:
REVERSE(character_expression )
如
select REVERSE(‘abcdefg’) from dual;
—-
gfedcba
现在说怎么计算从后向前出现的下标值
实验开始
select instr(REVERSE(‘abcdefg’),’f’) from dual;
—–
2
那么
select instr(REVERSE(‘abcdefg’),’f’,-1,1) from dual;
—
??是多少呢,回复吧
Any person several opportune pieces, it comes surely, as well as you bring in crave of various the many other types of hikers close to you with hard part your question. pre owned awnings
I ralely needed to find this info, thank God!