Question:
What is difference between SUBSTR and INSTR?
Answer:
SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDE INSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-') Source: CoolInterview.com
select substr('abcde',4) gives the output as de because it counts quotation also as a string so it eliminates till 4 char i.e('abc)and gives the output as above
select instr('abcde',4) gives the output as 0 Source: CoolInterview.com
Answered by: visu | Date: 12/11/2007
| Contact visu
# SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output BCDE INSTR provides character position in which a pattern is found in a string. eg INSTR('ABC-DC-F','-',2) output 7 (2nd occurence of '-') Source: CoolInterview.com
Answered by: mura | Date: 12/22/2007
| Contact mura
SUBSTR:- returns a specified portion of a string eg:- SUBSTR('GANGAA',5) ->output GANGA INSTR:- provides character position found in a string. eg INSTR('KHAIRATABAD','A',3) ->output 8 (3RD occurrence of 'A') Source: CoolInterview.com
Answered by: GP | Date: 11/24/2008
| Contact GP
substring is used to return the portion of the string eg:substr('str',2) output is :ta it will start count from the single quotation
instr is used to return the position of the mentioned string eg: instr('sta','a') output is : 3 It wont start it count from single quotation Source: CoolInterview.com
Answered by: prasanna venkatesh | Date: 4/2/2009
| Contact prasanna venkatesh
substring is used to return the portion of the string eg:substr('str',2) output is :tr it will start count from the single quotation
instr is used to return the position of the mentioned string eg: instr('sta','a') output is : 3 It wont start it count from single quotation Source: CoolInterview.com
Answered by: prasanna venkatesh | Date: 4/2/2009
| Contact prasanna venkatesh
Substr retrieves the string at the required position as Instr retrieves the string position only Source: CoolInterview.com
Answered by: Mandala Rajesh | Date: 11/12/2009
| Contact Mandala Rajesh
SUBSTR returns a specified portion of a string eg SUBSTR('BCDEF',4) output is EF But INSTR provides character position From where we start searching in a string eg. INSTR('ABCDAESVFDCNCW','C',1,2) the output will be 11.. The syntex is INSTR('The String','The character we want to search'the starting position of searching,Occurrence of that character) ... Source: CoolInterview.com
Answered by: Surajit Guin | Date: 6/3/2010
| Contact Surajit Guin
most of member provided wrong answer here regarding SUBSTR.this is correct please efer it.
SUBSTR('abcde'2) output:bcde
SUBSTR('abcde',2,3) output:bcd Source: CoolInterview.com
Answered by: sarika | Date: 8/20/2010
| Contact sarika
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|