Curriculum
Course: SQL
Login

Curriculum

SQL

SQL References

0/80

MySQL Functions

0/139

SQL Server Functions

0/84

SQL Quick Ref

0/1
Text lesson

INNER JOIN

INNER JOIN

The INNER JOIN command retrieves rows with matching values in both tables. The following SQL selects all orders along with corresponding customer information:

Example

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:

Example

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);