May 21, 2008

Substr 與 Instr

Example : String "one two three/four/five/"
Need to get before first "/" word->"three"

substr : get part of string by your parameter.
instr : return the position that match you input parameter.
instr('abcb','b',-1) -> search the 'b' location from the end to start , return from start to end position.

select trim(substr(substr('one two three/four/five/',1,instr('one two three/four/five/','/')-1),instr(substr('one two three/four/five/',1,instr('one two three/four/five/','/')-1),' ',-1))) from dual;

0 意見: