The JOIN operator matches rows by comparing values in one table with values in another. You decide which columns from each table should be matched. You have several choices:
SELECT *
FROM discounts INNER JOIN stores
ON stores.stor_id = discounts.stor_id
For more information on joining tables on related columns, see Joining Tables Automatically.
SELECT au_lname,
au_fname,
pub_name,
authors.state
FROM authors INNER JOIN publishers
ON authors.state
= publishers.state
For more information on joining tables on unrelated columns, see Joining Tables Manually.
Note also that you use multiple columns to match rows from the joined tables. For example, to find the author-publisher pairs in which the author and publisher are located in the same city, you use a join operation matching the respective state columns and the respective city columns of the two tables. You need to match both city and state because it is possible that different states could have like-named cities (e.g., Springfield, Illinois and Springfield, Massachusetts).
For more information on joining tables on multiple columns, see Joining Tables on Multiple Columns.
See Also