Skip to content

LEFT

  • string: The original string from which the leftmost characters will be extracted.
  • length: The number of characters to extract from the left side of the original string.
SELECT Orders.OrderID, Customers.CustomerName
FROM Orders
LEFT JOIN Customers ON Orders.CustomerID = Customers.CustomerID;
OrderIDCustomerName
1David
2Maria
3NULL

The LEFT JOIN keyword returns all records from the left table (Orders), and the matched records from the right table (Customers). If there is no match, the result is NULL on the right side. In this scenario, the third order has no corresponding CustomerID in the Customers table, hence the NULL in the output.