Use this tab if you have more than one table in your query.
When you include more than one table in a query, the tables must somehow be joined. This tab allows you to define your joins.
When you specify tables in the Tables tab, the Query Editor tries to generate a default join condition. It does this for two reasons. First, the Query Editor processes the query as you create it. If there is no default join, the tables create a cross product, and this can result in slow processing. Secondly, the Query Editor suggests a join strategy that might work for you.
If you add tables in the Query Editor Tables tab, the Query Editor checks to see if a foreign key relationship has been created between the tables. If there is one foreign key, it uses it to generate an ON condition. If there is more than one foreign key relationship, it uses the first one it finds. If there are no foreign keys, it does not generate an ON clause and the tables become a cross product.
You can always review your query by clicking the SQL tab, which is located at the bottom of the Query Editor dialog. You can edit your join strategy directly on the SQL tab, or you can use the Joins tab user interface to change it.
All the fields in the Joins tab are resizable. You can also expand the Query Editor by pulling on its edges. You may need to resize the fields and dialog in order to read your table names.
Left table expression – Select a table from the dropdown list. Only tables that have been entered in the Tables tab are available. Placing a table on the right or left is significant for outer joins.
Join type – Select a join type from the dropdown list.
Right table expression – Select a table from the dropdown list. Only tables that have been entered in the Tables tab are available. Placing a table on the right or left is significant for outer joins.
Condition – Double-click to create an ON condition, if desired. The Query Editor inserts the keyword ON. For key joins and natural joins, the ON condition is generated by Adaptive Server Enterprise.
Add/Delete – Use to add or delete lines. Click the gray circle to the left of the line to select the line. You must delete blank lines. This does not affect the tables in your query: to add or delete a table, use the Tables tab.
Results – This pane displays the results of your query, or an error message if the query contains errors.
SQL – Click SQL at the bottom of the dialog to see the SQL code for your query.
When you add more than one table to a query, the Query Editor attempts to create a default join strategy. If it cannot find a foreign key relationship between the tables, the default is a cross product. In most cases, cross products are not desirable.
To add or edit the join strategy, choose a table, a join type, and another table, all from the dropdown lists. Alternatively, click the SQL tab and edit the code directly.
For more information, see Introducing the Query Editor.