When you want to select specific data from one or more sources, you can use a select query. A select query helps you retrieve only the data that you want, and also helps you combine data from several data sources. You can use tables and other select queries as data sources for a select query. This topic provides an overview of select queries, and gives steps for creating a select query, by using the Query Wizard or in Design view.
If you want to use the Northwind sample database to learn more about how queries work, see the article Introduction to queries.
In this article
When you want to use data, you rarely want to use all of the data from one table. For example, when you want to use data from a Contacts table, you usually want to look at one specific record, or maybe just the telephone number. Sometimes you want to combine data from more than one table, such as combining Customer information with Order information. To select the data that you want to use, you use a select query.
A select query is a database object that shows information in Datasheet view. A query does not store data, it displays data that is stored in tables. A query can show data from one or more tables, from other queries, or from a combination of the two.
Benefits of using a query
A query lets you:
View data only from the fields you are interested in viewing. When you open a table, you see all the fields. A query is a handy way to save a selection of fields.
Note: A query only points to data, it does not store data. When you save a query, you are not saving a copy of the data.
Combine data from several data sources. A table usually only displays data that it stores. A query lets you pick and choose fields from various sources, and specify how the information should be combined.
Use expressions as fields. For example, you could use the Date function as a field, or you could use the Format function with a field to control the way the data from the field is formatted in the query results.
View records that meet criteria that you specify. When you open a table, you see all the records. A query is a handy way to save a selection of records.
Basic steps to create a select query
You can create a select query by using the Query Wizard or by working in Design view. Some design elements are not available when you use the wizard, but you can add these elements later by using Design view. Although the two methods are somewhat different from each other, the basic steps are essentially the same:
Choose the tables or queries that you want to use as sources of data.
Specify the fields that you want to include from the data sources.
Optionally, specify criteria to limit the records that the query returns.
After you have created a select query, you run it to see the results. To run a select query, you open it in Datasheet view. If you save the query, you can reuse it whenever you need, for example, as a data source for a form, report, or another query.
Use the Query Wizard to create a select query
You can use the Query Wizard to automatically create a select query. When you use the wizard, you have less control over the details of the query design, but the query is usually created faster than if you did not use the wizard. Moreover, the wizard can catch some simple design mistakes and prompt you to perform a different action.
Before you begin
If you use fields from data sources that are not related to each other, the Query Wizard asks you if you want to create relationships. The wizard opens the Relationships window for you, but you must restart the wizard if you edit any relationships. Therefore, before you run the wizard, consider creating any relationships that your query needs.
For more information about creating table relationships, see the article Guide to table relationships.
Use the Query Wizard
On the Create tab, in the Queries group, click Query Wizard.
In the New Query dialog box, click Simple Query Wizard, and then click OK.
Next, you add fields. You can add up to 255 fields from as many as 32 tables or queries.
For each field, perform these two steps:
U