Many times you will need data from more than one table to display on your report. To fetch data from two or more relational tables, you will code a join. The inner join syntax is preferable when you code the join as compared to the older technique of listing the table names without an explicit reference to a join operation.
To learn how work with inner joins, follow these steps:
inner joinkeywords. In addition, I've provided a table alias for each table (e.g., "c" for the Cities table) that I use to qualify potentially ambiguous references (e.g.,
namethat appears in both tables). I use the alias in the select list of columns and in the
onclause. Furthermore, note that in the
oncondition I check to make sure the state abbreviation in the Cities table is equal to the state abbreviation in the States table. This is necessary so that I display the correct state name for that city. If we omit the
oncondition then each city would be joined to each state, producing a much larger (and incorrect) result!