Join tables in a SELECT statement
Use the Join Tables window to join tables in a SELECT statement.
You must select more than one table for a SELECT statement before you can
join tables.
The Join Tables window assists you in performing joins on two or more
selected tables. Tables that you
selected in the FROM (Source tables) node are listed, and tables that can be joined
together are indicated. You can specify join types or select from
suggested join types. You can view details for each table including
column names, data types, primary keys, and whether columns are
nullable.
These steps are part of the larger task of creating a SELECT
statement. When you complete the steps for joining tables in a SELECT
statement, return to Create a SELECT
statement.
To join tables in a SELECT statement:
- In the Details area for the FROM (Source tables) node, click Join
Tables to open the Join tables window. If no primary/foreign key
relationships exist between the tables that you selected in the
FROM (Source tables) node, a message appears informing you that no join conditions
will be suggested in the Join Tables window, and some of the features
described below are not available.
- Optional: Keep the Suggest join conditions when joining check box
selected to activate a function that will suggest potential join paths when
you join tables together.
- Select a table in the Joins area. If any of the other
tables in the Joins area are potential candidates for a join with
this table, the icon next to these tables changes to a
.
- Hold down the Shift key or the Ctrl key and select another table.
- Click Join.
- If you selected the Suggest join conditions when joining check
box and one or more join paths exist between the two tables, a window opens
where you can select from all possible join paths for the two tables.
In the Suggest Joins window:
- Select a join path.
- Click OK. In the Joins area, a join will
appear in the outline with a
icon next to it. In the Details area, you can view and edit
the join conditions and join type.
- If you cleared the Suggest join conditions when joining check
box and no join paths exist between the two tables, a warning window opens to
inform you that no join paths exist. Click OK to close the
warning window. In the Joins area, a join is displayed in
the outline with an
icon next to it. In the Details area, you can view and edit
the join conditions and join type. You must specify valid join
conditions before you can save changes in the Join Tables window.
- If you cleared the Suggest join conditions when joining check
box, a join appears with an
icon next to it. In the Details area, you can view and
edit the join conditions and join type. You must specify valid join
conditions before you can save changes in the Join Tables window.
- Optional: Change the join type.
- Optional: Edit the join conditions.
- Optional: Add another table to the join by selecting a join in the
Joins area and following steps 4 through 7 above.
- Optional: Combine two joins by selecting two tables that are already joined in the Joins area and following steps 5 through 7 above.
- Click OK. All valid joins are added to the SQL code
view.
Return to Create a SELECT statement.