What Are Queries?

Learning Outcomes

  • Define queries in Microsoft Access
  • Create a query

Having a database full of information is great, but it does not do the business any good if it cannot be used to make decisions. The ability to extract information from a database so that it is useful for decision-making starts with the “query.” Simply speaking, a query is a question being asked of the data to inform the business.

A query of a database like Access gives you the ability to bring data together in a coherent manner, whether it resides in one or multiple tables. The query is the heart of “Business Intelligence” (BI) and the foundation of the Search. For example, a business may wish to know where the sales of its new product are occurring by zip code; or, who the top 5 suppliers to the business are.

Practice Question

Create a Query

Access provides query capability in the form of wizards to help create the query. To create a query, select “Create” from the tool bar and then “Query Wizard.” This will open the “New Query” window where you can choose among 4 wizards.

Create has been selected in the toolbar and the New Query window has popped up revealing four options: Simple Query Wizard, Crosstab Query Wizard, Find Duplicates Query Wizard, and Find Unmatched Query Wizard.

In our example, choose “Simple Query Wizard.” This wizard gives the option of choosing the table and the field for the query.

Simple Query Wizard window open showing the following items: Text that reads "Which fields do you want in your query? You can choose from more than one table or query." A drop down menu with the label "Tables/Queries" and "Table: Customers" selected in that dropdown menu. Two additional boxes labeled Available Fields and Selected Fields. There are a series of buttons positioned between Avalible Fields and Selected fields that allow the user to move fields in and out of "Selected Fields". "ID" is selected in Available Fields and no fields have been moved to the Selected Fields.

Let’s say that we are interested in knowing the status of Purchase Orders. Since this data is distributed across 2 tables, a query is the ideal way to gather this information. For this query we will need to select the “Purchase Order” table and several fields contained there as the example below.

Simple Query Wizard window. In the Tables/Queries dropdown menu, "Table: Purchase Orders" is selected. "Selected Fields" include Purchase Order ID, Supplier ID, Status ID, and Submitted By.

We then need to add data from the “Purchase Orders Status” table, so we select that and the “Status” field as in the example below.

Simple Query Wizard window open showing identical information to the previous image but with the field "Status" in the Selected Fields box.

The completed query brings together the information we requested in datasheet format and from here can be sorted, edited, resized or otherwise revised.

Complete query presents information in the form of a datasheet. The datasheet shown here includes the following information: Purchase Order ID, Supplier ID, Status ID, Submitted By, and Status.

PRactice Question