7. 9. 2. Performing Inner Joins on Multiple Columns Using SQL/92 |
|
If your join uses more than one column from the two tables, you provide those columns in your ON clause along with the AND operator. |
SELECT ...
FROM table1 INNER JOIN table2
ON table1.column1 = table2.column1
AND table1.column2 = table2.column2;
|
|
You can further simplify your query though the USING clause, but only if you're performing an equijoin and the column names are identical. |
For example, the following query rewrites the previous example with the USING clause: |
SELECT ...
FROM table1 INNER JOIN table2
USING (column1, column2);
|
|