MySQL8 LEFT() Functions – String Functions
MySQL LEFT() Functions: Syntax
MySQL LEFT() Functions: Description
LEFT() function fetches a number of characters from a string, starting from left. It will return NULL, if any of the argument is NULL.
If length parameter has more than the number of characters in string, then string will be returned.
MySQL LEFT() Functions: Parameter
[table caption=”” width=”100%” colwidth=”15%|30%|55%” colalign=”left|left|left”]
Name, Required /Optional, Description
string, Required, it is a valid input string.
length, Required, it specifies the length of characters to be fetched.
[/table]
MySQL LEFT() Functions: Output
[table caption=”” width=”100%” colwidth=”20%|80%” colalign=”left|left”]
Return, Description
String, returns the leftmost length characters from the string .
NULL, if any argument is NULL.
[/table]
MySQL LEFT() Functions: Available from
[table caption=”” width=”100%” colwidth=”25%|75%” colalign=”left|left”]
Version, MySQL 4.0
[/table]
MySQL LEFT() Functions: Example 1
mysql> SELECT LEFT('tutorialmines',NULL); +----------------------------+ | LEFT('tutorialmines',NULL) | +----------------------------+ | NULL | +----------------------------+ 1 row in set (0.06 sec)
MySQL LEFT() Functions: Example 2
mysql> SELECT LEFT('tutorialmines',8); +-------------------------+ | LEFT('tutorialmines',8) | +-------------------------+ | tutorial | +-------------------------+ 1 row in set (0.00 sec)
MySQL LEFT() Functions: Example 3
mysql> SELECT LEFT('tutorialmines',28); +--------------------------+ | LEFT('tutorialmines',28) | +--------------------------+ | tutorialmines | +--------------------------+ 1 row in set (0.00 sec)
See all MySQL String functions MySQL 8 String Functions.