Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Search in string from right

Search in string from right

From: <marpe1974_at_yahoo.se>
Date: 18 Apr 2006 00:29:03 -0700
Message-ID: <1145345343.550659.82690@g10g2000cwb.googlegroups.com>


Hi all,

I'm trying to select the first part of a string (before charachter
'-'). An example of the string is '123456-03' and the result should be
'123456'. This is perfectly done by the following code:

SELECT SUBSTR(RESOURCESTRING,1,INSTR(RESOURCESTRING , '-')-1) FROM ACCESSLOG
WHERE INSTR(RESOURCESTRING , '-')>0 My problem is that the string 'RESOURCESTRING' could have more than one
'-' (example 'Z-334455-02' and it is the last occurence that is the
correct. The sql above finds the first occurence of '-' and stops there. It will give me the result 'Z' instead of 'Z-334455'.

How could this be done? Is there a way to search the string from right?

Martin Received on Tue Apr 18 2006 - 02:29:03 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US