Reading a part of a string in SQL

August 4, 2009 at 21:03:32
Specs: Windows XP
I have a table with one column " otname "
table1.otname contains multiple rows of alpha-numeric string resembling the following data sample:

11.10.32.12.U.A.F.3.2.21.249.1
2001.1.1003.8281.A.LE.P.P
2010.1.1003.8261.A.LE.B.B

I want to read the fourth number in every string ( part of the string in bold ) and write a query in Oracle 10g
to read its description stored in another table. My dilemma is writing the first part of the query.i.e. choosing the fourth number of every string in a table

My second query will be something like this:

select description_text from table2 where sncode = 8281 -- fourth part of the data sample in every string

Many thanks.

novice


See More: Reading a part of a string in SQL

Report •


#1
August 11, 2009 at 00:19:59
Apologies it's not an exact answer: I can only speak from
MySQL experience but you may be able to find something
equivalent in oracle:

SELECT 
SUBSTRING_INDEX(SUBSTRING_INDEX(fieldname, '.', 4), '.', -
1)

Alias this and you can use it in your "WHERE" clause


Report •
Related Solutions


Ask Question