ComponentOne Query 8.0
Two-Way Joins

A two-way outer join is an outer join where C1Query can change the order of the participating views (tables). The default order in an outer join is:

Example Title
Copy Code
A LEFT OUTER JOIN B

Where A is the view in the left combo box, and B is the view in the right combo box. Here each of the two, A and B, corresponds to a single table if the corresponding view is a single table view, and to all the constituent tables if it is a multi-table view.

If the selected join type is outer, inner or full, C1Query will always apply this join in the specified order. For inner and full joins the order does not make any difference, changing the order produces an SQL statement equivalent to the original one, always yielding the same result. For outer joins, however, the order is sometimes essential.

In some cases, it is desirable to allow the end user to specify the order explicitly. In these cases, the order of a join may depend on the end user query, it is determined by the order of result fields with non-empty sort (ascending or descending). For join relationships with two-way outer joins, C1Query takes the sort order into consideration when it generates the SQL statement. It attempts to add tables to the SQL statement in the order specified by the end user. Then the order of tables in the generated FROM clause reflects the order of result fields with non-empty sort in the user query. When this is impossible, C1Query generates the best possible approximation, where sorted fields occurring earlier in the list of result fields take precedence over fields occurring later.

Considering the necessity of two-way outer joins, keep in mind that in most cases the order of tables in the FROM clause does not make any substantial difference, it is only important in special cases. It does not make any difference with inner joins. And the sort conditions specified by the end user are always guaranteed to produce the correct sorting of the result, regardless of the join type. If you are not worried about the implications of changing the order of tables in the FROM clause, there is no need to be concerned about the join type.

 

 


Copyright (c) GrapeCity, inc. All rights reserved.

Product Support Forum  |  Documentation Feedback