Click here to Skip to main content
15,888,286 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900