Syntax:
table [alias][, table [alias][, ...]]
or
table [alias] joinspec table [alias] ON joinpredicate [ joinspec table [alias] ON joinpredicate ...]
The parts of this clause have the following meaning:
Part | Meaning |
table | A source table from which the data is to be retrieved. |
alias | An alias for the table, usually to differentiate it from another instance of the same source table |
joinspec | Syntax: INNER | LEFT | RIGHT JOIN
INNER JOIN returns only rows that match the criteria in both tables LEFT JOIN returns all rows from the left table and inserts nulls into the appropriate fields where no matching row exists in the right table RIGHT JOIN returns all rows from the right table and inserts nulls into the appropriate fields where no matching row exists in the left table |
joinpredicate | A condition on which the tables are joined |
Example usage:
SELECT FirstName, LastName FROM Contact SELECT DISTINCT A.Name AS Manager, B.Name AS Subordinate FROM Payroll A INNER JOIN Payroll B ON A.ID = B.Supervisor