The INNER JOIN command retrieves rows with matching values in both tables. The following SQL selects all orders along with corresponding customer information:
SELECT Orders.OrderID, Customers.CustomerName FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID; |
Please note that the INNER JOIN keyword selects all rows from both tables only if there is a match between the columns. Orders without corresponding customers will not be displayed.
The following SQL statement selects all orders along with customer and shipper information:
SELECT Orders.OrderID, Customers.CustomerName, Shippers.ShipperName FROM ((Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID) INNER JOIN Shippers ON Orders.ShipperID = Shippers.ShipperID); |