Joining Database Objects Together
Up until this point, only reports based on a single table, view, stored procedure, or SQL Command have been discussed. However, it is quite common to have several disparate database objects in the same report. Crystal
Because of Crystal Reports' inherent basis on relational data, any time multiple tables are used, they must be linked together so that the sum of all database objects is a single set of relational records. The good news is that most of the time, Crystal Reports takes care of this automatically, and the report developer need not worry about linking.
To see this in action, create a connection to the Xtreme Sample Database and add both the Customer and Orders tables to the report. When clicking
By default, Crystal Reports creates links based on name. In this case, both tables have fields with a name of Customer ID, so a link is already created. To accept this link, simply click Next to move to the next step in the Report Wizard. If there were not a common field name, selecting the By Key option and clicking Auto-Link would attempt to create a link based on the fields defined in the database as keys. If
After links are created, you can configure them by clicking on the link arrow connecting two tables (it turns blue when selected), and then clicking the Link Options button. Links have two options: join type and link operator. These settings determine how Crystal Reports matches records from both tables. The default join type is an inner join, which means that only records with a matching key in both tables are included. The default link type is equal. For most cases, these two settings do not need to be modified.
Understanding the Different Join Types
The capability to enforce links created in a report is new to version 10. Enforcing a link between two tables ensures that this link will be used in the report's respective SQL, regardless of whether fields are required from either or both of the involved tables. The default setting is Un-enforced links, meaning that the link will only be used if the report's respective SELECT statement requires it. Access to the different enforcing options is provided by right-clicking on a link and selecting the Link Options menu item.
After a report is created, select Database Expert from the Database menu to return to the Data Explorer. Here tables and SQL Commands can be added, removed, and