Tue. Oct 15th, 2024
How to Write Query in Microsoft Access
How to Write Query in Microsoft Access

This tutorial is explaining about how to write query in access. This is one of the most basic tutorial for beginner in Microsoft Access. Query in Ms Access is the Access object used to review, add, update, or delete data from the Access database. Query can create totals or other conditional fields.

To create Query, go to Create tab > Queries group > then select Query Wizard or Query Design.

 

Create Query with Query Wizard

1. After you select the Query wizard, New Query dialog box will appear.

2. In the dialog box, select one of the Wizards:
a. Simple query: creating the simple, most common query
b. Crosstab query: create the query in crosstab manner. For more information and how to, read: Crosstab Query Access 2013
c. Find Duplicates Query Wizard: the query purposed to find duplicates records
d. Find Unmatched Query Wizard: to compare two tables and find records that the value is not matched.
3. Depends on the selected Wizard, the next dialog box will be varied.

how to write query in access-1
how to write query in access-1

In simple query wizard, select the table or query to taken from. Then, choose the fields to be taken and displayed.
4. Next, review the Query name. Then, you’re finished.

Read Also:  Ms Access Query Examples on Expression Syntax Functions

 

Create Query with Query Design

Creating query using query design is more recommended, because it has more options to show more than one table/queries along with the criteria.
1. After you selecting the Query Design, a query design window will appear, along with the Show Tables dialog box. Choose the tables/queries to be created.

how to write query in access-2
how to write query in access-2

2. In the table, double click the field to show it into the field grid.

 

how to write query in access-3
how to write query in access-3

 

how to write query in access-4
how to write query in access-4

 

Field: show the field name
Table: show the field’s table source.
Sort: Ascending or Descending
Show: To display the field in Datasheet view
Criteria: to add specific condition for displayed records in Datasheet view
Or: to add more Criteria.
3. In Design tab > click Run.

READ: Ms Access Query Examples
READ: What Is Query In Ms Access

 

Writing SQL in Query

With Query Wizards, you can create the query, but you cannot create the condition or criteria for query. To do that, follow these steps:
1. Open the previously created query. In Home tab, switch the view to SQL view.
2. Now, write the SQL code for query. The code is using SQL language so you must at least learn to code in SQL. The most basic syntax’s in SQL are:
SELECT [field1], [fieldn]
FROM [table1]
WHERE [criteria];

Read Also:  Powershell Query MS Access Database in Microsoft Windows Application
how to write query in access-5
how to write query in access-5

 

3. In the design tab, click Run to apply the changes.