| Step by step exercise. Simple queries (II) |
| Objective. |
| Practice the operations for Creating a simple query and include search criteria |
| Exercise 1. |
|
1 Open the Classes.mdb database. 2 Position yourself on Queries tab in the Database window. 3 Double-click on the Create
a Query in Design view option, or, click on the Next will open the Show table box. 4 Click on the Students table, it will remain selected if it was not already before. 5 Click on the Add button. Observe how the Students table appears in the tables area of the design window. 6 Click on the Close button to close the dialogue box as the query is going to be based only on the Students table. Now we will add the Name, Surname, City, and Date of Birth fields 7 Click on the Field: row in the first column of the grid. 8 Drop down the associated list by clicking on drop down list arrow. 9 Select the Student name field. 10 Double-click on Student surname in the table.This is another way of adding fields to the grid. 11 Drago the City field from the table to the grid.This is another way of adding fields to the grid. 12 Include the Date of birth field the way you prefer. The grid will appear in the following way:
13 Click on the run button 14 Now we will save the query, click on the 15 Write the name that we would like to give to the query, My Students. Look out! we may not give it the same name as a table already created. 16 Click on the
|
| Exercise 2. |
|
1 Select in the Database window the query we want to edit, My Students, by clicking on it. 2 Click on the 3 Click on the Criteria: row in the Date of birth column. 4 Write <01/01/67 in order to indicate the "[Date of birth] < #01/01/67#" condition. Observe how Access has enclosed the date between # #.. The QBE box will appear in the following way:
5 Run the query by clicking on
the 1 Drop down the File menu and select the Save as... option. 2 Write another name, Students before 67. 3 Click on the OK button (or press Enter key). 4 Close the query by clicking
on the
|
| Exercise 3. |
|
1 Select the query to edit, Students before 67 by clicking on it. 2 Click on the 3 Click on the Criteria: row in the City column. 4 Type Los Angeles. In this case it is not necessary to type the operator as it is =, just the value must be type and it does not need to be enclosed between inverted commas, Access will automatically add them. The QBE box will appear in the following way:
As the conditions are placed in the same row, the query will recover record that comply with both criteria. In other words, all the students from Los Angeles AND born before 67 will appear. 5 Execute the query by clicking on
the Note one student from the other list does not appear (Mario) as he is from Las Vegas.
1 Drop down the File menu and select the Save as... option. 2 Type Students from Los Angeles and before 67. 3 Click on the OK button. 4 Close the query by clicking on
the |
| Exercise 4. |
|
1 Select the query to edit, My Students, by clicking on it. 2 Click on the 3 Click on the Sort: row in the Student surname column. 4 Click on the arrow to drop down the list and select Ascending in order to sort from A to Z. The QBE box will appear in the following way: 5 Run the query by clicking on
the 1 Drop down the File menu and select the Save as... option. 2 Write the name as Students by surname. 3 Click on the OK button. 4 Close the query by clicking
on the
|
|
|
|
Legal warning: Authorised on-line use only. It is not allowed the use of these courses in companies or private teaching centres.
|
|
© aulaClic. All rights reserved. Reproduction in any form whatsoever is prohibited.
April-2006.
|