SQL LEFT Function

SQL LEFT() function is used to get left part of a string with the length of specified number. It is supported by MySQL, MS SQL Server, Access, but not by Oracle.

SQL LEFT Function Syntax

LEFT(str, len)

Note:
1, If str is NULL, the return value will be NULL.
2. If len is greater than the length of str, the return value will be the entire str.
3. If len is 0, the return value will be empty string.

SQL LEFT Function Example

SELECT LEFT('SQL Tutorial',3)
-- The return value will be: SQL
SELECT LEFT('SQL Tutorial',0)
-- The return value will be: Empty string
SELECT LEFT(NULL,3)
-- The return value will be NULL
SELECT LEFT('David',20)
-- The return value will be: David

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>