substr( string, start_position, [ length ] ) 只有这三个参数,举个例子就明白了
substr('烂桐helloword',2,4) 结果是ello,就是说从helloword这个字符串中取值,从第二个开始取,一共取4个。不会有1个参数的,最少2个,就是这样的substr( string, start_position ),意思是如果饥肆坦不给出取的长度的参数,就默认取到最后的。 顺便说一句:[ ] 这个大括弧的意思就是可有可无,其他的雹拆是必须有的
取得字符串中指定起始位置和长度的字符串
substr( string, start_pos, [ 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 结果是 te
select substr('emros',-3,1) value from dual 结果是物山 r
substr('abcde'档蚂答,-6) = null
substr('abcde',-5) = 'abcde'
substr('abcde',-4) = 'bcde'
substr('abcde',-3) = 'cde'行慧
substr('abcde',-2) = 'de'
substr('abcde',-1) = 'e'
substr('abcde',-0) = 'abcde'