Click here to Skip to main content
14,300,703 members
Rate this:
Please Sign up or sign in to vote.
See more:
I want take out some string values between two particular positions.
I tried using below query but it did not work out as excepted i used sub_string and position functions.

Please help me on this ..

that indx is a column its values will be like this
Create index index on cust_branch_item_stock_bkp(c_item_code,c_c2code,c_br_code,n_bal_qty,t_ltime,n_rate)


need output:

c_item_code,c_c2code,c_br_code,n_bal_qty,t_ltime,n_rate

What I have tried:

select SUBSTRING(indx,POSITION('(' IN indx)+1,POSITION(')' IN indx)-1) from db_index_list


current output:
c_item_code,c_c2code,c_br_code,n_bal_qty,t_ltime,n_rate)"
Posted
Updated 10-Sep-19 20:46pm
v2
Comments
Maciej Los 11-Sep-19 2:52am
   
What's input?

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

The third argument to SUBSTRING is the length of the substring, not the end position. This will work:
SELECT SUBSTRING(indx, POSITION('(' IN indx) + 1, POSITION(')' IN indx) - POSITION('(' IN indx) - 1) from db_index_list
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100