About joining tables or queries in a query (MDB)

Microsoft Office Access 2003

When you add more than one table or query to a query, you need to make sure their field lists are joined to each other with a join line so that Microsoft Access knows how to connect the information.

Join line shows relationship between tables

Callout 1 Join line

If you previously created relationships between tables in the Relationships window, Access automatically displays join lines when you add related tables in query Design view. If referential integrity is enforced, Access also displays a "1" above the join line to show which table is on the "one" side of a one-to-many relationship and an infinity symbol Button image to show which table is on the "many" side.

ShowJoins not defined in relationships

Even if you haven't created relationships, Microsoft Access automatically creates joins if you add two tables to a query and the tables each have a field with the same or compatible data type and if one of the join fields is a primary key. The "one" and "many" symbols are not displayed in this case, because referential integrity is not enforced.

Sometimes the tables you add to the query don't include any fields that can be joined. In this situation, you have to add one or more extra tables or queries to serve solely as a bridge between the tables whose data you want to use. For example, if you add the Customers and Order Details tables to a query, they won't have a join line between them because they don't have any fields that can be joined. But the Orders table is related to both tables, so you can include the Orders table in your query to provide a connection between the other two.

Extra table in a join provides relationship between tables

ShowTypes of joins

ShowInner joins

Once tables and queries are joined, and you've added fields from both tables or queries to the design grid in query Design view, the default join tells the query to check for matching values in the join fields. (This is called an inner join.) When it finds matches, it combines those two records and displays them as one record in the query's results.

Join line between field lists in query Design view makes an inner join

Callout 1 The symbols above the join line indicate the type of relationship, in this case, "one" to "many."

Callout 2 If one table doesn't have a matching record in the other table, neither record appears in the query's results.

Callout 3 Inner join

ShowOuter joins

If one table or query doesn't have a matching record in the other table or query, neither record appears in the query's results. If you want the query to select all the records from one table or query whether or not it has matching records in the other table or query, you can change the join type to an outer join.

Join line between field lists in query Design view makes an outer join

Callout 1 An arrow points to the table contributing only the matching records.

Callout 2 The query displays empty cells where there is no matching record from another table.

Callout 3 Outer join

ShowUnequal joins

If you want the query to select records based on the value in the join field being greater than, less than, not equal to, greater than or equal to, or less than or equal to the value in the other join field, you must create an SQL statement in SQL view.

ShowCross-product or Cartesian product joins

If tables in a query aren't joined to one another, either directly or indirectly, Microsoft Access doesn't know which records are associated with which, so it displays every combination of records between the two tables. Therefore, if each table had 10 records in it, the query's results will contain 100 records (10X10). This result set of every possible combination is called a cross product or Cartesian product. These queries might take a long time to run and ultimately might produce less meaningful results.