Difference between SUBSTR and INSTR

Editorial / Best Answer

Answered by: Shiv Mangal Rahi

  • Jul 24th, 2006


Hi All,

INSTR function finds the numeric starting position of a string within a string.

As eg.

Select INSTR('Mississippi','i',3,3) test1,

         INSTR('Mississippi','i',1,3) test2,

         INSTR('Mississippi','i',-2,3) test3

from dual;

Its output would be like this

Test1           Test2              Test3

___________________________________________

11                   8                     2

SUBSTR function returns the section of thte specified string, specified by numeric character positions.

As eg.

Select SUBSTR('The Three Musketeers',1,3) from dual;

will return 'The'.

Showing Answers 1 - 2 of 2 Answers

Nagarajan.R

  • Jul 18th, 2005
 

INSTR (String1,String2(n,(m)), 
INSTR returns the position of the mth occurrence of the string 2 in 
string1. The search begins from nth position of string1. 
 
SUBSTR (String1 n,m) 
SUBSTR returns a character string of size m in string1, starting from nth postion of string1. 
 

  Was this answer useful?  Yes

Shiv Mangal Rahi

  • Jul 24th, 2006
 

Hi All,

INSTR function finds the numeric starting position of a string within a string.

As eg.

Select INSTR('Mississippi','i',3,3) test1,

         INSTR('Mississippi','i',1,3) test2,

         INSTR('Mississippi','i',-2,3) test3

from dual;

Its output would be like this

Test1           Test2              Test3

___________________________________________

11                   8                     2

SUBSTR function returns the section of thte specified string, specified by numeric character positions.

As eg.

Select SUBSTR('The Three Musketeers',1,3) from dual;

will return 'The'.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions