LEFT Function [String]

Returns a specified number of characters from the beginning of a string.

Syntax

LEFTstring-expression, numeric-expression )

Parameters

Parameters

Parameter

Description

string-expression

The string.

numeric-expression

The number of characters to return.

Returns

LONG VARCHAR

LONG NVARCHAR

Note: The result data type is a LONG VARCHAR. If you use LEFT in a SELECT INTO statement, you must have an Unstructured Data Analytics Option license or use CAST and set LEFT to the correct data type and size.

Remarks

If the string contains multibyte characters, and the proper collation is being used, the number of bytes returned may be greater than the specified number of characters.

Note: The result data type of a LEFT function is a LONG VARCHAR. If you use LEFT in a SELECT INTO statement, you must have an Unstructured Data Analytics option license or use CAST and set LEFT to the correct data type and size.

Standards and Compatibility

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase—Not supported by Adaptive Server Enterprise.

Example

The following statement returns the value “choco”:

SELECT LEFT( 'chocolate', 5 ) FROM iq_dummy
Related reference
LCASE Function [String]
LOWER Function [String]
REPLACE Function [String]
REVERSE Function [String]
RIGHT Function [String]
UCASE Function [String]
UPPER Function [String]