tags:

views:

1558

answers:

2

How can I get the character at position 4 in a field?

e.g.

field contents = "hello"

I want to return the value of position 2 = "l"

A: 

In sql server you can use SUBSTRING

SELECT SUBSTRING('hello',3,1)

edit: this is not zero based.

astander
A: 

In Oracle, use SUBSTR

Syntax is SUBSTR(<string to parse>,<start position>,(<length>)) - i.e.

SELECT SUBSTR('hello',3,1)

Start position and length are one-, not zero-based. Zero is accepted, but will be interpreted as 1.

Ed Harper