Syntax:
INNER JOIN Table
ON TableColumn = TableColumn
What does it do?
Joins multiple tables together. Matching the rows together
where the values are equal that are selected with the ON portion of the statement.
It returns only the rows that have matching values in both tables.
The dot(.) that is placed inbetween the table name and the column name
denotes that the column belongs to that table. It is necessary to use a
TableName.ColumnName if the same column name exists in both tables.
Example:
SELECT
Customers.FirstName,
Orders.OrderID,
Orders.Total
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID
= Orders.CustomerID;
Example - using aliases:
SELECT
C.FirstName,
O.OrderID,
O.Total
FROM Customers AS C
INNER JOIN Orders AS O
ON C.CustomerID
= O.CustomerID;
Results:
FirstName |
OrderID |
Total |
John |
1 |
$10.00 |