How to get a part of the string ?
How can i get
1 out of '1 - Jack' or
26 out of '26 - Dave' or
436 out of '436 - Michael' ???
There is a blank space on either side of Hiphen (_-_). I want to get the numeric part of the string only, be it 1 digit 2 digit or whatever...
I am using Oracle9i SQLplus.
Re: How to get a part of the string ?
hi
i have never used Oracle, but in SQL we do it like this. If i want to get
lets Assume you have a Field "Description" and it Contains
'1 - Jack' And from this you want to Extract 1
Code:
select substring(Description,1,1)
from MyTable
Its Simple you see
Re: How to get a part of the string ?
I don't know about Oracle syntax, but for SQL Server you could use something like this:
Left(fieldname, CharIndex(fieldname,' ') -1 )
Re: How to get a part of the string ?
Ditto on Oracle, also
Left(fieldname, Instr(fieldname, ' ') - 1)