You are on page 1of 2

Access Queries Introduction

Select Queries

When you want to review data from specific fields in a table, or review data from multiple tables
together, a select query is your choice.

 Open the tables from which you want to view fields from
 On the Create tab either use the Query Wizard or the Query Design in the Query Group
 Drag or Double Click the fields you want to add to the Query Design grid
 Type in the criteria of choice
 Run your query

Comparison Operators

 All common comparison operators can be used in Select Queries including: =, <, >, <=, >=, as well
as <> (not equal)

Data Types and Syntax

 Common data types in Access include: Number, Date, and Text including other more specialized
ones
 All comparison operators can be used with these common data types
 However when adding criteria for each of the 3 data types, syntax differs as follows:
o Number criteria: type in the value or combinations of values being searched for without
any other special characters
o Text criteria: text being searched for must be enclosed in Double Quotes “ “
o Date criteria and format: specific dates being searched for must be enclosed in Pound
Signs # # with a default format being Year, Month, Day format
 The DatePart function can be used to separate the date into each of it’s 3 parts
with syntax: DatePart(Interval,date)
 Common Interval options include: yyyy – for year, m – for month, d – for
day, or h – for hour (e.g. DatePart(“yyyy”,[datefield]) in the field row of
your query builder window and the date to be searched for, say 2020, in
your criteria row)

Parameter Queries

When you frequently want to run variations of a same query, use a parameter query. When you
execute a parameter query, Access prompts you for field values, and then uses the values to create the
criteria for your query.

 In the Navigation Pane, right click and choose an existing query or create a new one using the
Create tab (above)
 In the Query Design grid in the Criteria row of a field column Type your prompt (e.g. [For What
City?] (Note that a period (.) or an exclamation point (!) can be used as text in a parameter
prompt)
 Select the check box in the Show row of the filed you have chosen (e.g. City column), so the
query will display the City
 On the Design tab, in the Results group, click RUN. The query will prompt you for a city
Access Queries Introduction

 Type in a City (e.g. New York) and press Enter to see your results

Wildcards

There are various combinations of letters and partial data strings that can be searched for using
Wildcards including “Like”, *, ?

 Some examples are:


o Like “To*”
o Like “*l”
o Like “???R*”
o Like “*R*”

And/Or

 To run a select query with querying contents of both one field AND the contents of another
field, add to your criteria of choice for each of the fields.
 Note that when the criteria is on the same row of the query this implies an AND condition to
Access.
 When the criteria is on the next row (OR), it implies one result or another

Calculations Queries

Any calculation using numeric fields in existing tables can be used in calculations (note that common
symbols such as: +, -, *, /, () are used and the Order of Operations is applied.

 A general example includes Subtotal: ([Quantity]*[Unit Price])-([Quantity]*[Unit


Price]*[Discount]) Note the brackets and order of operation
 Other specific example using Orders and Order Detail Total Price:[Quantity]*[Price]

You might also like