left()

Extracts the substring with the specified length from the left side of the given string. If the length of the string is shorter than the specified length, this returns the entire string. If the argument is null, this returns null, and if this receives a value other than the string, it evaluates the value after converting it to a string.

Syntax

left(STR_EXPR, CHAR_LENGTH)
Required Parameters
STR_EXPR
String expression
CHAR_LENGTH
Number of characters to be extracted. The function returns the string after truncating as many characters from the left of the string as you specified. If the length of the string is shorter than the specified length, the function returns the entire string. You can only provide constants greater than or equal to 0.

Usage

left("0123456789", 4) => "0123"
left("0123456789", 11) => "0123456789"
left("0123456789", 0) => ""
left(1234, 2) => "12"
left(1.23, 3) => "1.2"
left(null, 3) => null