Returns the leftmost characters in a string value, based on a specified number of characters.

Syntax

LEFT(expression, numChars)

Arguments

  • expression: a character expression of one of these types, or an expression that resolves to one of these types:
    • CHAR
    • VARCHAR
    • LONG VARCHAR
  • numChars: the number of characters to return, starting from the first (left) position in expression. This value should be an INTEGER.

Returns

  • The same type as the input expression. Returns NULL if expression evaluates to NULL.

Examples

SELECT firstName, LEFT(firstName, 5) AS firstNameLeft5 FROM MYSQL.inventory.cust;

-- VALUES LEFT('Adamson');
-- Returns 'Adams'