Book Contents

Book Index

Next Topic

Home

SUBSTRING

SUBSTRING returns a VARCHAR value representing a substring of a specified string.

Syntax

SUBSTRING (string , position [ , extent ] )

SUBSTRING (string FROM position [ FOR extent ] )

Semantics

 

string

(CHAR or VARCHAR) is the string from which to extract a substring

position

(INTEGER) is the starting position of the substring (counting from one)

extent

(INTEGER) is the length of the substring to extract. The default is the end of the string.

Notes

Examples

=> SELECT SUBSTRING('123456789', 3, 2);

substring

-----------

34

(1 row)

=> SELECT SUBSTRING('123456789' FROM 3 FOR 2);

substring

-----------

34

(1 row)