MySQL LEFT Function

MySQL Left function is one of the String methods, which returns the leftmost characters of the user-specified expression. This left function uses its second argument to decide how many characters it has to return as the output.

In this article, we show how to write the MySQL String left Function using Command Prompt and Workbench with an example, and the basic syntax of it is as shown below:

SELECT LEFT (String_Expression, value)
FROM Source

For this demonstration, we are going to use the below shown data.

Table 1

MySQL Left Function Example

This method returns the leftmost characters in a given string. The following string function query shows multiple ways to use this.

SELECT LEFT('Learn MySQL Server', 11) AS `Leftmost Characters`;

SELECT LEFT('Tutorial Gateway', 8) AS `Leftmost Characters`;
Left Function Example 1

It also allows you to return the leftmost characters of the data inside a table. In this MySQL example, we are going to find the leftmost characters of all the records present in the Department Name and Email column.

SELECT  FirstName, LastName, 
        LEFT(DepartmentName, 8) AS `First 8 Characters in Department`,
        LEFT(Email, 4) AS `First 4 Characters in Email`
FROM employe
ORDER BY FirstName, LastName;
MySQL LEFT Function Example 2