Tuesday, November 30, 2010

Selecting some part of a text by using substr, instr

To take characters beginning from 3.:
select substr('This is a test', 3) from dual :"is is a test"

To take 2 characters beginning from 3.:
select substr('This is a test', 3, 2) from dual :"is"

To count characters till a character:
select instr('This is a test', 's') from dual : "4"

Of course using the combination of substr and instr is possible; To take characters beginning from a character;
select substr('This is a test', (select instr('This is a test', 's') from dual)) from dual : "s is a test"

No comments:

Post a Comment