Operation Manual

Creating queries
Queries are used to get specific information from a database. Query results are special tables
within the database.
To demonstrate the use of queries, we will use two different methods:
Using our CD-Collection table, we will create a list of albums by a particular artist. We will
do this using the Wizard.
The information we might want from the Fuel table includes what our fuel economy is. We
will do this using Design View. (Queries that require calculations are best created with
Design view.)
Using the Wizard to create a query
Queries created by the wizard provide a list or lists of information based upon what one wants to
know. It is possible to obtain a single answer or multiple answers, depending upon the
circumstances.
In the main database window (Figure 211), click the Queries icon in the Database section, then in
the Tasks section, click Use Wizard to Create Query. The Query Wizard window opens (Figure
243). The information we want is what albums are by a certain musical group or individual (the
album’s author). We can include when each album was bought.
Note
When working with a query, more than one table can be used. Since different tables
may contain the same field names, the format for naming fields in a query is Table
name.field name, with a period (.) between the table name and the field name. For
example, the Lunch field of the Vacation table used in a query has the name
Vacation.Lunch.
Figure 243: First page of the Query Wizard
Step 1: Select the fields
1) Select the CD-Collection table from the drop down list of tables.
2) Select fields from the CD-Collection table in the Available fields list.
a) Click Artist, and use the > button to move it to the Fields in the Query list.
b) Move the AlbumTitle and DatePurchased fields in the same manner.
c) Click Next.
254 | Getting Started with LibreOffice 5.1