The main purpose of relational database lies in the ability to quickly retrieve and analyzing data by running a query. Queries allow you to extract information from one or more tables based on a set of search condition given by you. This tutorial will help you in acquiring the complete knowledge on query, how to design it and how to Run The Query Wizard In Access Application. Throughout this tutorial you will also learn how to create a simple one-table query.
What are queries?
Queries are mainly the way of searching and compiling data from one or more tables. Running query is same like as you are an asking detailed question of your database. Building a query in access means that you are defining specific search condition to find exactly the data you want.
What’s the need of using the query?
Though there are options like searches or filters to find data within a table but queries are such powerful option that can draw information from multiple tables.
Let’s take an example: while you uses a search in customer table to find the name of one customer at your business or using a filter option on the other table to view only orders placed from the last weeks. Using a any of this two option can you view both customers and a order at the same time.
Well this is possible with the query option. You could easily run query to find the name and phone number of every customer’s who done shopping within past weeks.
When you run a query, the outcome are shown in table, but at the time of designing you can use different view. This is called Query Design view, and this allows you to see how your query is put together.
STEPS TO RUN THE QUERY WIZARD IN ACCESS
With the Access option of “query wizard” you have to enter the table or field information, and the simple query wizard will take care of the rest. So let’s start knowing how you can create a query.
- First of all write down the data you want to keep in your query results.
A query gives a datasheet so make your layout in that format. So all you need is column headings so you will know what data to pull from database.
- Determine the table location of each data from your paper.
Write down the table and filed name that contain the data matching the column heading on the paper above the column heading.
- In your database window, tap to the create tab option from the ribbon and then click the Query Wizard button from the queries section.
This will open a New Query Wizard dialog box, asking you what kind of query wizard you want to run. Just choose the Simple Query Wizard and click Ok.
- Select the first table you want to include in your query. You will use the Tables/Queries drop-down menu, which displays all the tables in your database. Click the down arrow next to the Tables/Queries drop-down menu. Click the name of the table or query you wants to include in this query.
- Choose the fields from the table of your query. For each field that you want to include in the query, click the name of the table or query to include this query. In the Available Fields list, make a double tap on each filed from this table or query that you want to include in the query you are creating.
- After selecting all the fields click to the Next
If the wizard can determine the relation between the tables you selected, a window appears. But if you don’t see such window then also doesn’t worry because Access just wants you to name the query instead.
If you have include fields from two tables that aren’t related to each other than a warning dialog box will appear automatically. This dialog box is to remind that all the selected tables must be related before you can run your query so that you will fix the issue and then continue.
- If the wizard ask you to choose between a detail and a summary query, click the
Radio button present as per your choice and then click Next.
Detail will create a datasheet that lists all records that match the query. As the name implies you will get every details from those records.
Summary tells the wizard that you are not interested in seeing every single record; this gives you the summary of the information instead.
If you want to make any special adjustment to the summary then click to the Summary Options to display the Summary Option dialog box. Select your summary option from the check boxes for the available functions and then click Ok.
- In the wizard page, select the radio button for what you to do next. Like:
To make your query snazzy: Select the Modify the Query Design option.
In this option the wizard will send your newly created query to the salon for some sprucing up, such as the inclusion of sorting and totals.
In order to skip the fancy stuff: Select the Open The Query To View Information option to see the Datasheet view.
In this option the wizard will run the query and presents the results in a typical Access datasheet.
- Now give a title to your query in the text box and at last click to the Finish option.
The wizard builds your query and save it with the same name you have given, then Access displays the results.
To create a simple one-table query:
- Select the create tab on the ribbon and locate the Queries
- Now tap to the Query Design
3. Access will switch to Query Design view. In the show table dialog box, select the table you want to run a query on. If you are running a query on the customer, so we will select the Customers.
4. Click Add, and then click to the Close option.
5. The selected will appear as a small window in the Object Relationship pane. In the table window, make a double click in the field names that you want to include in your query. This will get added to the design grid in the bottom part of the screen.
- Set the search criteria by clicking the cell in the criteria, row of each filed you want to filter. If you want to set multiple criteria but don’t need the record shown in your results to meet all of the, type the first criteria in the Criteria: row and additional criteria in the or: row and the rows beneath it. Because we want to find customers who live in Raleigh or in the 27513 zip code, we’ll type “Raleigh” in the City field and “27513” into the or: row of the Zip Code The quotation marks is to search these field for an exact match.
7. After you have set your criteria, run the query by clicking the Run command on the design tab.
8. The query result will appear in the query’s datasheet view, which looks like a table. If you want query by clicking the same command in Quick Access Toolbar. When prompted to name it, type the desired name then click ok.
Now you must have got a clear idea on how to create the simplest type of query with only one table. So, take the complete benefit of Access features.