Queries
Queries are used to manipulate the data in our tables. At this stage, we will only be using SELECT queries, which are
essentially customizable filters. Data can be retrieved based on criteria such as:
Fields and Tables The fields that should be displayed and the tables they are present in.
Records Records can be filtered by date, the text they contain, numbers over a set amount etc.
Order The records can be placed in a particular order.
When a query is executed, the results appear in a datasheet like the tables. This is a filtered display of data – the actual
tables have not been changed in any way. The tasks below use a query builder to produce a number of queries.
Task 1 – Building a Query
A database holding information about members of a bowling club was created in a previous exercise. If you did not
complete the task, then you will need to create a database for the data below. Name the database ‘Bowling’ and the
table ‘Members’.
ID FirstName LastName Registered Date Played
1 Sarah Johns Yes 01-Mar-08 5
2 Charles Collins No 4
3 Richard Chew Yes 01-Mar-08 5
4 Paul Logan Yes 05-Apr-08 5
5 Gareth Jones No 4
6 Amelia McDermott Yes 01-Mar-08 3
7 Lisa Beagley Yes 05-Apr-08 5
8 Mark Stone Yes 08-Mar-08 4
a. Open your ‘Bowling’ database and click on the ‘Create’ tab in the ribbon.
b. Click on ‘Query Design’ button.
c. Make sure the ‘Members’ table is selected in the ‘Show Table’ window and click ‘Add’. A small box showing the
fields in your table will appear in the query builder window. Close the ‘Show Table’ window.
Table
appears
here
d. Select ‘FirstName’ from the drop-down list in the first column. This field will be displayed first.
e. Select ‘LastName’ in the second column. Click on ‘Sort’ box and select ‘Ascending’ from the choices.
ORB Education Quality Teaching Resources
ORB Education Visit http://www.orbedu.com for the full, editable versions with solutions. CoP022 - Access Standards
f. Select ‘Played’ in the third column. In the ‘Criteria’ box, type ‘=5’. This will return only records for the people
who have played 5 games.
Type ‘=5’ in the
‘Criteria box’
g. Run the query by clicking on the ‘Run’ button (although clicking on the ‘Datasheet view’ icon will do the same
thing in this case). How many records and fields are returned?
Use this icon to switch
between ‘Datasheet View’
and ‘Query Design View’.
h. Return to ‘Design view’ and remove the check from the ‘Show’ box in the ‘Played’ column. How many records
and fields are returned now?
Remove the
check from
the ‘Show’
box in the
played
column.
i. Close the query and name it ‘Played5’.
Task 2 – Further Queries
Create the following queries and explain in plain English what results they return. In each case, mention the fields,
the records and the sort order.
a. Query name - Registered
______________________________________________________________________________________
______________________________________________________________________________________
b. Query name – RegisteredLate
______________________________________________________________________________________
______________________________________________________________________________________
ORB Education Quality Teaching Resources
ORB Education Visit http://www.orbedu.com for the full, editable versions with solutions. CoP022 - Access Standards