Tutorial Gateway

  • C
  • C#
  • Java
  • Python
  • SQL
  • MySQL
  • Js
  • BI Tools
    • Informatica
    • Talend
    • Tableau
    • Power BI
    • SSIS
    • SSRS
    • SSAS
    • MDX
    • R Tutorial
    • QlikView
  • More
    • C Programs
    • C++ Programs
    • Python Programs
    • Java Programs
    • SQL FAQ’s

MySQL LEFT Function

by suresh

MySQL Left function is one of the String Functions, 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.

In this article, we show how to write MySQL String left Function using Command Prompt, and Workbench with example.

MySQL LEFT Syntax

The basic syntax of LEFT in MySQL is as shown below:

SELECT LEFT (String_Expression, value)
FROM Source

For this string left function in MySQL demonstration, we are going to use the below shown data

MySQL Left Function Example 1

MySQL Left Example 1

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

-- MySQL String Left Example
SELECT LEFT('Learn MySQL Server', 11) AS `Leftmost Characters`;

SELECT LEFT('Tutorial Gateway', 8) AS `Leftmost Characters`;

OUTPUT

MySQL LEFT Example 1

MySQL Left Example 2

The string left in MySQL 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.

-- MySQL String Left Example
USE mysqltutorial;
SELECT  FirstName, LastName, 
		DepartmentName, 
        LEFT(DepartmentName, 8) AS `First 8 Characters in Department`,
        Email,
        LEFT(Email, 4) AS `First 4 Characters in Email`
FROM employe
ORDER BY FirstName, LastName;

OUTPUT

MySQL LEFT Example 2

Placed Under: MySQL

  • How to Download MySQL
  • Install MySQL on Windows
  • MySQL Create Database
  • MySQL Delete Database
  • MySQL Create Table
  • MySQL Drop Table
  • MySQL SELECT Statement
  • MySQL ALIAS Column
  • MySQL Distinct
  • MySQL Insert Statement
  • MySQL Delete
  • MySQL Truncate Table
  • MySQL WHERE Clause
  • MySQL Order By
  • MySQL Group By
  • MySQL Having Clause
  • MySQL LIMIT
  • MySQL Arithmetic Operators
  • MySQL COALESCE Function
  • MySQL AND Operator
  • MySQL NOT Operator
  • MySQL OR Operator
  • MySQL XOR Operator
  • MySQL BETWEEN Operator
  • MySQL Not Between Operator
  • MySQL GREATEST Function
  • MYSQL LEAST Function
  • MySQL LIKE Operator
  • MySQL NOT LIKE Operator
  • MySQL IFNULL Operator
  • MySQL NULLIF Operator
  • MySQL INTERVAL Operator
  • MySQL IS Operator
  • MySQL IN Operator
  • MySQL NOT IN Operator
  • MySQL IS NOT NULL
  • MySQL IS NULL
  • MySQL Inner Join
  • MySQL Cross Join
  • MySQL Right Join
  • MySQL Left Join
  • MySQL Aggregate Functions
  • MySQL Date Functions
  • MySQL Date Function
  • MySQL String Functions
  • MySQL Numeric Functions
  • C Tutorial
  • C# Tutorial
  • Java Tutorial
  • JavaScript Tutorial
  • Python Tutorial
  • MySQL Tutorial
  • SQL Server Tutorial
  • R Tutorial
  • Power BI Tutorial
  • Tableau Tutorial
  • SSIS Tutorial
  • SSRS Tutorial
  • Informatica Tutorial
  • Talend Tutorial
  • C Programs
  • C++ Programs
  • Java Programs
  • Python Programs
  • MDX Tutorial
  • SSAS Tutorial
  • QlikView Tutorial

Copyright © 2021 | Tutorial Gateway· All Rights Reserved by Suresh

Home | About Us | Contact Us | Privacy Policy