totn MariaDB Functions

MariaDB: LEFT Function

This MariaDB tutorial explains how to use the MariaDB LEFT function with syntax and examples.

Description

The MariaDB LEFT function allows you to extract a substring from a string, starting from the left-most character.

Syntax

The syntax for the LEFT function in MariaDB is:

LEFT( string, number_of_characters )

Parameters or Arguments

string
The string that you wish to extract from.
number_of_characters
The number of characters that you wish to extract from string starting from the left-most character.

Note

  • If number_of_characters exceeds the length of string, the LEFT function will return string.

Applies To

The LEFT function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB LEFT function examples and explore how to use the LEFT function in MariaDB.

For example:

SELECT LEFT('TechOnTheNet.com', 1);
Result: 'T'

SELECT LEFT('TechOnTheNet.com', 4);
Result: 'Tech'

SELECT LEFT('TechOnTheNet.com', 6);
Result: 'TechOn'

SELECT LEFT('TechOnTheNet.com', 99);
Result: 'TechOnTheNet.com'