Garayed.com  

Go Back   Garayed.com > Oracle
FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-18-2006, 08:29 AM
marpe1974@yahoo.se
 
Posts: n/a
Default Search in string from right

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:55 PM.




LinkBacks Enabled by vBSEO 3.0.0 © 2007, Crawlability, Inc.