
Chapter 7: Databases and Data Sources
1. Click the Queries icon on the left side of the database window.
2. Click Create Query in Design View.
3. The Add Tables window opens in front of the Query Design window. Add both
tables to the query.
4. Click Close in the Add Tables window.
5. Add the following fields from the Appointments table: Subject, Location, Start
date, Start time, End date, End time, Notes.
6. Add the TypeName field from the Types table.
7. In the Start date column, on the Criterion row, enter any date such as
3/9/1972.
8. Click the Switch Design View On/Off button. The SQL statement that underlies the
query is now visible. Toward the end of the statement something like the following
appears: AND (("Appointments"."Start date" = {D ' 1972-03-
09'})). This statement finds records where the Start date equals the date 3/9/1972.
9. Replace {D '1972-03-09'} with the text CURRENT_DATE and click the Switch
Design View On/Off button again.
10. Click the Run Query button. The query results appear at the top of the resulting
window.
11. Save the query as Appointments for Today and close the query.
If the database does not contain appointments for today, add an appointment for today and
rerun the query by double-clicking on it.
Add a sort order to the query
There will be days with more than one appointment. In that case, it would be useful to sort
the results of the query.
1. Open the query for editing by right-clicking the icon for the query and choosing Edit.
2. To add a sort order to a column, click in the Sort row in that column. The Sort row is
just below the Table row. Click the Sort row in the Start time column.
3. Click the drop-down for Sort and choose Ascending.
4. Set the Sort to Ascending for the End date and End time fields as well.
5. Save the query.
If the database contains appointments for the current day, try running the query.
Changing the Join type in the query
When the query is run, as it exists currently, some appointments won't appear.
OpenOffice.org User Guide for 2.x 374
Comentarios a estos manuales