📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

LEFT



Returns the leftmost len characters from the string str, or NULL if any argument is NULL. If len is greater than the length of str, the entire str is returned.

Syntax

LEFT(<str>, <len>);

Arguments

ArgumentsDescription
<str>The main string from where the character to be extracted
<len>The count of characters

Return Type

VARCHAR

Examples

SELECT LEFT('foobarbar', 5), LEFT('foobarbar', 10); ┌──────────────────────────────────────────────┐ │ left('foobarbar', 5) │ left('foobarbar', 10) │ ├──────────────────────┼───────────────────────┤ │ fooba │ foobarbar │ └──────────────────────────────────────────────┘

Was this page helpful?