Beginner

244. LEFT Function

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

📘 Lesson 244 of 728 ⏱ 8 min 🎯 Beginner

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

LEFT provides a simple way to extract prefixes, codes, and identifiers from text values.

Extract the first two characters of a branch code.

SQL
SELECT
    BranchCode,
    LEFT(BranchCode, 2) AS RegionCode
FROM Branches;

LEFT is useful for region codes, product prefixes, customer identifiers, and data classification.

  • LEFT extracts characters from the beginning.
  • The number of characters is specified.
  • It is useful for prefixes.
  • It simplifies common substring operations.
  • Function support varies by database.
What does LEFT do?

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

When would you use LEFT?

LEFT is useful when you need to extract prefixes or leading characters from a text value.

Have you finished this lesson?

Introduction to SQL – All Lessons