LEFT function [String]

Function

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

Syntax

LEFT ( string-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 datatype of a LEFTfunction 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 datatype 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 Sybase IQ System Administration Guide