0

I wrote a query which splits a string and show me as a value I want using SUBSTR

    SELECT SUBSTR ('imagelocation/r1.jpg', 15)   AS image_location  FROM dual

I am getting the output as r1.jpg but I only want the value to come as r1. Please help

3 Answers 3

1

If you want something more universal, regexp_replace might be of use.

SELECT 
regexp_replace('imagelocation/r1.jpg','^[^/]*/([^.]+).*$','\1') AS image_location 
FROM dual;
Sign up to request clarification or add additional context in comments.

Comments

1
select SUBSTR (
         'imagelocation/r1.jpg', 
         INSTR('imagelocation/r1.jpg', '/')+1,
         LENGTH('imagelocation/r1.jpg') - INSTR('imagelocation/r1.jpg', '.') - 1
       ) AS image_location  
FROM dual

SUBSTR Function in Oracle

SQL Fiddle

Comments

0

Try this:

SELECT SUBSTR('imagelocation/r1.jpg',15,2) AS image_location FROM dual

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.