Previous Next JavaScript must be enabled to correctly display this content

## substring function

The `substring` function extracts a string from a given string according to a given numeric starting position and a given numeric substring length.

    returnvalue substring (source, position [, substring_length] )

    source ::= any*
    position ::= integer*
    substring_length ::= integer*
    returnvalue ::= string

Example: Fetch the first three characters from the routing details of a passenger with ticket number 1762376407826.

    SELECT substring(bag.baginfo.routing,0,3) AS Source
    FROM baggageInfo bag
    WHERE ticketNo=1762376407826

Output:

    {"Source":"JFK"}