LEFT function [String]

Function

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

Syntax

LEFTstring-expression, numeric-expression )

Parameters

string-expression The string.

numeric-expression The number of characters to return.

Example

The following statement returns the value “choco”:

SELECT LEFT( 'chocolate', 5 ) FROM iq_dummy

Usage

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.

NoteThe result data type of a LEFT function is a LONG VARCHAR. If you use LEFT in a SELECT INTO statement, you must have a Large Objects Management option license or use CAST and set LEFT to the correct data type and size.

See “REPLACE function [String]” for more information.

Standards and compatibility

See also

“RIGHT function [String]”

Chapter 11, “International Languages and Character Sets” in the System Administration Guide: Volume 1