Retrieve the first 3 characters from a string.
SELECT Left(“SQL Tutorial”, 3) AS ExtractString; |
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.
Left(string, number_of_chars) |
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. |
Works in: |
From Access 2000 |
Retrieve the first 5 characters from the text in the “CustomerName” column.
SELECT Left(CustomerName, 5) AS ExtractString FROM Customers; |