previous page

Introduction | Create Database | Tables & Keys | Data Types | Link Tables | Basic Query | More Queries

next page
Lab 11: Databases - Microsoft Access

Querying the database


To retrieve information from the database we use formulate queries

Our first query will ask to see all the data in the fields Performer, PerformanceDate, Venue and Address. The result of the query will look like this:

query result

This result shows us that the database now holds information about 3 events, all on different dates and with different performers in 2 locations.

NOTICE: that Paramount Theater and its address show up twice even though we only had to type it into the database once. This is the essence of why relational databases are efficient.

The query to get this answer looks like the image below. To create this query, feel free to try to figure it out yourself (then skip to step #5), or follow the directions below.:

query

 

1. Click on the Create tab, the click on the Query Design icon:

1

You'll see this:

1

2. The Show Table window lets you indicate which tables you want to include in your query. In this case, we want to include all three. You can either highlight one at a time, or all three at once, then click on the Add button to add it/them to your query to get this:

1

The three tables are displayed at the top of the query page. Notice that the relationships are shown automatically (because you've already defined them). The lower part of the page is where you'll indicate what you want to display from those three tables.

3. Double-click on Performer in tablePerformers. It will be inserted in the query definition below as shown below. The Show check box will automatically be selected (if you unselect it, that field won't appear in the result).

1

 

4. Double-click on additional field names until you get this:

query

 

5. To see the results of the query, go to the Design tab and click on the Run icon (shown below):

1

Your results should look like the image below (it doesn't matter if your fields are in a different order left-to-right):

query result

 

Next, you'll learn some query strategies

previous page Introduction | Create Database | Tables & Keys | Data Types | Link Tables | Basic Query | More Queries next page