Thursday, February 26, 2009

Querying A Database:

1. Open MS Access
2. From the file menu choose “open”.
3. “Point” to your database file that you saved on the network and click “open”.
4. You will then see the Database window shown below.
5. Select the query tab and then click the new button; ie. Let’s make a new query.
6. You will then be prompted for the type of format you would like to work with. Select design view.
6. You will now see two windows; “select query” and “show table”. You only have one table to work with. Your table is probably called “address”. Select it and click “add”. You should now see the table appear in the upper section of the “select query” window as shown below. You can now close the add table window.


7. Drag the field name “Surname” from the table into the first column of the row called “field” as shown above.
8. Drag “Name” and “Postcode” into the locations as shown. Enter a postcode you know is in your database; eg. 2145
9. Save the query (you will need to give it a name) then close it. The original database window should now be visible. You should notice that your query is now listed in the window.
10. Ensure your query is highlighted and then choose “open”.
11. What you now have displayed are the results of your query.

What sort of information has the query selected?
The query has selected all the information of the people with the post code 2146, which are mine and Shamona’s.


12. We can alter any query as follows. Firstly close the query and return to the main database window. With the “query” tab selected choose “design”. In the “or” row in the postcode column enter another postcode from your database; eg. 2146. Save and view the results of the query as before.

What sort of information has this second query selected?
It has now brought up the information from both the post codes 2146 and 2151 and the other information that came with.



13. Design the following queries and describe the type of information they are selecting.


Query 3 shows all the phone numbers which have the number *2* in them.


Query 4 shows all the phone number which have the number *3* in them.


14. Create the following queries and test to see they work. Record the fields and criteria you used for each query.

a) Postcode of 2145 or 2146.


b) Postcode between 2140 and 2170.


c) Surnames starting with F.


d) Surnames or first names containing "m".


e) Surnames and first names containing "a".

0 comments: