What is the usage of the SQL LEFT function?
The LEFT function in SQL is used to retrieve a specified number of characters from the left side of a string. The syntax is as follows:
LEFT(string, length)
In this case, “string” refers to the string that needs to be cut, and “length” specifies the number of characters to be cut.
Suppose we have a table called employees, with a column named name storing the names of the employees. If we want to retrieve the first three characters of each employee’s name, we can use the LEFT function.
SELECT LEFT(name, 3) FROM employees;
This will return a result set containing the first three characters of each employee’s name.