Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

Left

Example

Retrieve the first 3 characters from a string.

SELECT Left(“SQL Tutorial”3AS ExtractString;

Definition and Usage

The Left() function extracts a specified number of characters from the beginning of a string.

Note: Also consider using the Right() function for extracting characters from the end of a string.

Syntax

Left(stringnumber_of_chars)

Parameter Values

Parameter

Description

string

Required. Specifies the string from which characters will be extracted.

number_of_chars

Required. Specifies the number of characters to extract. If this parameter exceeds the length of the string, the function will return the entire string.

Technical Details

Works in:

 From Access 2000

More Examples

Example

Retrieve the first 5 characters from the text in the “CustomerName” column.

SELECT Left(CustomerName, 5AS ExtractString
FROM Customers;