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 be joined somehow. 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. In most cases, cross products are not desirable. Secondly, the Query Editor suggests a join strategy that might work for you.
If you add tables in the 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 window. You can edit your join strategy directly on the SQL tab, or you can use the Joins tab user interface to change it. See Joins: Retrieving data from several tables.
Tip: 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 window 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. See Joined tables.
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. The Query Editor inserts the keyword ON. For key joins and natural joins, the ON condition is generated by SQL Anywhere. See Explicit join conditions (the ON clause).
Add Use to add lines. Click the gray circle to the left of the line to select the line.
Delete Use to 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 window to see the SQL code for your query.
If you receive an error message indicating that your join is not correct, click the SQL tab at the bottom of the window to review the SQL code. It may happen that empty quotation marks or extra commas have been inserted in your code, particularly if you have added and deleted lines on the Join tab. For example, the following query produces an error message. You need to delete the empty quotes that appear after SalesOrders:
FROM ("Customers" JOIN "SalesOrders")"" JOIN "SalesOrderItems"
|Discuss this page in DocCommentXchange.
Send feedback about this page using email.
|Copyright © 2009, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.1|