About creating a new query

Microsoft Query

Show All

About creating a new query

A query is a means of finding the records that answer a particular question you ask about the data stored in a database. When you create a query, you can either use the Query Wizard or work directly in Microsoft Query. How you create your query depends on the features you need to select the data you want.

When to use the Query Wizard   Use the Query Wizard when you want to create a simple query. By using the Query Wizard, you can select the tables and fields you want to include. An inner join is created automatically when the wizard recognizes a primary key field in one table and a field with the same name in the other table.

You can also use the wizard to sort the result set and do simple filtering. In the final step of the wizard, you can choose to return the data to Microsoft Excel, further refine the query in Query, or create an OLAP cube from the data. After you create the query, you can run it in either Excel or Query. How to use the Query Wizard.

When to use Microsoft Query   Use Query when you want to create a more complex query. This method gives you the most control because you can narrow your result set either by creating an inner join or outer join or by using expressions and complex criteria. Expressions are calculations you can make by using operators, functions, field names, and constants. You can do more complex filtering if you use criteria.

In Query, you can view the result set, and when you're sure it contains the data you want, you can return the data to Excel. You can also create OLAP cubes in Query. After you create the query, you can run it in either Excel or Query. How to create a query in Microsoft Query.

When to use a parameter query   Use a parameter query when you want to create one query to retrieve data that has different criteria. For example, to retrieve sales data for one product at a time, you can use the product name as the criteria. Parameter queries are also useful for retrieving part of the data from a database that is too large for your system's resources to retrieve all of the data at one time.

A parameter query prompts for criteria when you run it. You can create a parameter query only in Query, not in the Query Wizard. The criteria you enter are used to retrieve data from the tables in your query. After you create the query, you can run it in either Excel or Query. How to create a parameter query.