![]() |
| |||
| 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 |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |