The LEFT JOIN
command returns all rows from the left table, and the matching rows from the right table. The result is NULL from the right side, if there is no match.
The following SQL will select all customers, and any orders they might have:
SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID
ORDER BY Customers.CustomerName;
Try it Yourself »
Note: The LEFT JOIN
keyword returns all records from the left table (Customers), even if there are no matches in the right table (Orders).
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!