Progress
Results User’s Guide
for Windows


Creating a Query

There are three steps to creating a query:

NOTE: The instructions in this guide are based on the Sports database shipped with the Results application. If you have access to this sample database, you can use it while you learn how to use Results.

  1. Select the database tables to be included in the query.
  2. When you create a query, you select the tables that contain the information you want Results to retrieve.

  3. Select the view you want to use to process the information retrieved by the query.
  4. A view is an on-screen display of only part of the information in a database, as specified in a query. A view can display data from one or more tables or from other views.

    Table 3–1 lists these views.

    Table 3–1: Query Views 
    View
    Purpose
    Browse
    Lists records online in a tabular format similar to a spreadsheet. You can scroll forward and backward through the data.
    Report
    Creates multi-line and master-detail reports for printing. Provides calculated values and totals. You can format the headers, footers, and page breaks.
    Form
    Allows you to view, update, add, and delete individual records in the database.
    Label
    Formats and prints records in a variety of label formats, including mailing and inventory labels.
    Export
    Formats records to export to other applications.

  5. Select the fields you want to display.
  6. When you create a query, Results retrieves all the fields in each table you include in the query. However, you might want to limit the number of display fields, which are the fields that you select to appear in the view, whether on-screen or printed. For example, if you create a query that accesses the Customer table, you might want to view only those fields that contain address information. Limiting the display fields does not alter the contents of the query; it simply limits the number of fields you view.

Once you create the initial query, you can modify its contents, select a new query view, or select different display fields.

Follow these steps to create a query:

NOTE: The steps for selecting the display fields do not apply to the Label view. See "Using Query Views," for instructions on creating queries for the Label view.

  1. Choose Query New and a view for the query. The Add/Remove Tables dialog box appears:
  2. The Available Tables selection list shows the tables that comprise the database that you are connected to. If you are connected to more than one database, Results indicates the database in which each table resides.

  3. Select a table from the Available Tables selection list, then choose Add. The table appears in the Selected Tables selection list. The Available Tables selection list now displays only tables that have a relationship with the table you selected:
  4. Repeat Step 2 to add more tables.
  5. After you add tables, the Selected Tables selection list displays the relationships, or joins, among the tables in the query. For example, if you select the Customer, Order, and Order-Line tables, the Selected Tables selection list appears as follows:

  6. When you are done adding tables, choose OK. The Add/Remove Fields dialog box appears:
  7. The Available Fields selection list displays all the fields in the tables you selected. If you are connected to more than one database, Results indicates the database where each field in the list resides.

  8. Select one or more fields from the Available Fields selection list, then choose Add:
  9. To select multiple fields, press CTRL and click individual fields, or press SHIFT and drag the mouse to select a range of fields. The fields are displayed in the Selected Fields selection list in the order in which they will be displayed in the view (from left to right).

  10. To reorder the display fields, select a field and choose the Move Up or Move Down button. Repeat this process until the fields are listed in the order in which you want them to appear in the view.
  11. Choose OK to display the query in the Progress Results window.

The appearance of the query depends on the type of view you chose in Step 1. The following query illustrates the Browse view. See "Using Query Views," for more information about changing and using query views:

The status bar identifies the query view you are using and the database to which you are connected. If you are connected to more than one database, the status bar lists the first database to which you connected.

Each record in the view contains the information from the display fields you selected for the query. In this example, the records are composite records because they contain fields from more than one table. The data is displayed from left to right in the order you specified when you created the query.

The customer Lift Line Skiing appears several times because of the type of relationships between the tables. Each customer can have one or more orders, thus the relationship between the Customer and Order tables is a one-to-many relationship. Each order can have several line items, so the Order and Order-Line tables also have a one-to-many relationship. Results displays a composite record for each line item a customer orders.

For more information about relationships, see Results Overview."


Copyright © 2004 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095