INNER JOIN or Equijoin
The most important and most used JOIN is the INNER JOIN or equijoin. This joins two tables with common columns that match equally. These matching columns are usually a part of the primary key. The format is:
JOIN syntax: WHERE syntax:
SELECT t1.column1 AS ‘title1′, SELECT t1.column1 AS ‘title1′,
t2.column2 AS ‘title2′, … t2.column2 AS ‘title2′, …
FROM table1 [AS] ‘t1′ FROM table1 [AS] ‘t1′,
INNER JOIN table2 [AS] ‘t2′ table2 [AS] ‘t2′
ON t1.column1 = t2.column2[, ...] WHERE t1.column1 = t2.column2[, ...]
[GROUP BY t1.column1] [GROUP BY t1.column1]
[HAVING BY t1.column1] [HAVING BY t1.column1]
[ORDER BY t1.column1 [ASC|DESC]] [ORDER BY t1.column1 [ASC|DESC]]
The join is called an INNER JOIN because only those rows that meet the join condition in both tables are described as “inside” the join.
> JOIN is synonymous with INNER JOIN.
> The WHERE syntax is simpler and easier to understand for INNER JOINs. However, both syntax formats are shown in each topic so that you can understand and use either format.
> You can substitute the USING clause for the ON clause.
Access, DB2, and SQL Server do not support the USING clause.
MySQL requires the USING columns to be qualified by the table name.