Beginner

309. LEFT Function

Learn how to extract a specified number of characters from the beginning of a string.

📘 Lesson 309 of 728 ⏱ 8 min 🎯 Beginner

The LEFT function returns a specified number of characters from the beginning, or left side, of a string.

Many business identifiers contain meaningful prefixes. LEFT can extract those prefixes for classification and analysis.

Extract the first three characters from an employee code.

SQL
SELECT
    EmployeeCode,
    LEFT(EmployeeCode, 3) AS BranchCode
FROM Employees;

LEFT is useful for extracting product prefixes, branch codes, country codes, and identifier segments.

  • LEFT extracts characters from the beginning.
  • The number of characters can be specified.
  • It is useful for code extraction.
  • It supports text transformation.
  • Some databases use different syntax.
What does LEFT do?

LEFT returns a specified number of characters from the beginning of a string.

Where can LEFT be useful?

LEFT can extract meaningful prefixes from employee codes, product IDs, account numbers, and other identifiers.

Have you finished this lesson?

Introduction to SQL – All Lessons