What is the purpose of the SQL LEFT function?
The LEFT function in SQL is used to return a specified length portion of the left side of a string.
Syntax: LEFT(string, length)
Explanation of parameters:
- String: the string to be trimmed.
- length: length of the string to be returned.
Points to consider:
- Return the entire string if the value of ‘length’ is greater than the length of the string.
- If the value of length is 0 or negative, return an empty string.
- If string is NULL, then return NULL.
原文: 我需要一个更有挑战性的工作,这份工作对我来说太容易了。
重述:I need a more challenging job. This job is too easy for me.
SELECT LEFT('Hello World', 5) AS Result;
The output is:
Hello
In the example above, the LEFT function will return the leftmost 5 characters of the string ‘Hello World’, which is ‘Hello’.