The LEFT function returns a specified number of characters from the left side of a text value in database systems that support this function.
Extracting prefixes is common when working with product codes, employee IDs, branch codes, and other structured identifiers.
Extract the first three characters of an employee code.
SELECT
LEFT(EmployeeCode, 3) AS BranchCode
FROM Employees;
LEFT is useful for prefix extraction, code analysis, categorization, and data validation.
- LEFT extracts characters from the beginning.
- The second argument specifies the number of characters.
- It is useful for prefixes.
- Function availability varies by database.
- It can be combined with other string functions.
What does LEFT do?
LEFT returns a specified number of characters from the beginning of a text value.
Where is LEFT commonly used?
It is commonly used to extract prefixes from codes, IDs, and structured text.