Learning Guide # 5 LO 5: Retrieve Information: Unit of Competence: Operate Database Application
Learning Guide # 5 LO 5: Retrieve Information: Unit of Competence: Operate Database Application
GAGE COLLEGE
LEARNING GUIDE # 5
Unit of Competence : Operate Database Application
LO 5: Retrieve Information
Information Sheet 1: Retrieving Information
Queries
A query is a derived item in the database meant to answer specific questions that relate
to the information in the database. Queries are handy during data processing.
To find and retrieve just the data that meets conditions that you specify, including
data from multiple tables, create a query. A query can also update or delete multiple records at
the same time, and perform predefined or custom calculations on your data.
A query requests data from the database. At its simplest, a query merely fetches all
data from a single table. But as you create more complex (and more typical) queries, you can
assemble exactly the data you want (i.e. unique sets of data that you require at any given time).
Queries can also be used to execute mathematical and logical functions to obtain certain
information in the database.
Queries are derived from and linked to tables or other queries. (Due to these
linkages, they tend to largely inflate the size of the database and should thus only be used to
execute the intended functions, and stored only if updated information is to be retrieved)
There are various types of queries for different uses some of them are the following:
Select queries - A select query is the most common type of query. It retrieves data
from one or more tables and displays the results in a datasheet where you can
update the records (with some restrictions). You can also use a select query to
group records and calculate sums, counts, averages, and other types of totals.
Parameter queries - A parameter query is a query that when run displays its own
dialog box prompting you for information, such as criteria for retrieving records or a
value you want to insert in a field. You can design the query to prompt you for
more than one piece of information; for example, you can design it to prompt you
for two dates. Access can then retrieve all records that fall between those two
dates.
Parameter queries are also handy when used as the basis for forms, reports,
and data access pages. For example, you can create a monthly earnings report
based on a parameter query. When you print the report, Access displays a dialog
box asking for the month that you want the report to cover. You enter a month and
Access prints the appropriate report.
Delete Queries A delete query deletes a group of records from one or more
tables. For example, you could use a delete query to remove products that are
discontinued or for which there are no orders. With delete queries, you always
delete entire records, not just selected fields within records.
Update Queries An update query makes global changes to a group of records
in one or more tables. For example, you can raise prices by 10 percent for all
dairy products, or you can raise salaries by 5 percent for the people within a
certain job category. With an update query, you can change data in existing
tables.
Append Queries An append query adds a group of records from one or more
tables to the end of one or more tables. For example, suppose that you acquire
some new customers and a database containing a table of information on those
customers. To avoid typing all this information into your own database, you'd
like to append it to your Customers table.
Make-Table Queries A make-table query creates a new table from all or part
of the data in one or more tables. Make-table queries are helpful for creating a
table to export to other Microsoft Access databases or a history table that
contains old records.
Open your working database that you did last time then click on the Queries tab in the
database window. Create new query by clicking on the Create query in design view. Your screen
should resemble like this:
On the table row, click what table you want to get the field data that you want to extract. On
the Field row, choose whatever fields you want to display on your query then apply sorting by
choosing either ascending or descending order. On the show row, when checked, means that
the field you choses will be displayed when you run the query otherwise it will not be displayed
even if you choose it.
worksheet-like format as
right side.
If you want to filter out specific data, go back to design view then write on the field criteria the
data that you want to filter. In the example below, it would display the EmployeeID, Lastname,
Firstname, Middlename, Birthday & Address of those who resides in Addis Ababa.
Save the changes you made then close the query design view and open it. It will then
display all the records whose Address is “Addis Ababa” as shown below.