The LEFT()
function returns a specific number of characters from the left side of a string.
Figure 1 shows a visual representation of the LEFT()
function.
LEFT(string, numOfChars)
The LEFT()
function requires two parameters:
If a number instead of a string is sent as a parameter, then the number will be cast to a string and the function will then be applied.
The LEFT()
function returns the specific number of characters from the left side of a string sent as a parameter.
If the number of characters is greater than the actual length of the string, then this function returns the entire string.
-- string sentSELECT LEFT('HELLO',3);-- number of characters greater than length of stringSELECT LEFT('HELLO',7);-- number is sent instead of string-- it will be cast as a string and then left() is appliedSELECT LEFT(12345,2);