Wednesday, January 3, 2007

How to Understand the Query Design Window

I believe that the reason I found this so confusing in the beginning was that I did not have a good overview of what was going on.

You use the Query Design window to graphically create queries. It greatly simplifies the creation of most types of queries and also help avoid some of human errors that might enter in when the SQL for the query is created in text editor.

The window can create and edit several types of queries.
  • Select Query
  • Crosstab Query
  • Make-Table Query
  • Update Query
  • Append Query
  • Delete Query
These query options are under Query menu option. This menu option becomes available when a query is selected or created in design mode.

By default the window assumes you are creating a SELECT query. If you want a query other than the SELECT query, go the Query menu and select the type of query you want.

Depending on the query selected, there may be other information that has to be entered.

The Append query adds new records to a table using the INSERT SQL command.

Joins can be created for a Select query by adding the tables to the top section of Query Design window select the field to be joined on and than dragging the field to the matching field in the other dialog. The first dialog select is the left table and the second dialog is the right table. By default two table will be joined when placed in the upper table section of the window with they have a matching field label. The first table place in the section becomes the left table and the second table become the right table.

Although the design window may look the same between different queries, the SQL code generated and it functionality and be very different.

Is there some way that an interface could more clearly show the differences between types of queries?

There are also some other specialty types of queries that can be created by selecting one of the wizards rather than Design View in the New Query dialog.

This is a list of the options available in the New Query dialog:
  • Design View
  • Simple Query Wizard
  • Crosstab Query Wizard
  • Find Duplicates Query Wizard
  • find Unmatched Query Wizard
The wizard can simplify the creation a very complex query. The following was created using the Duplicate Query wizard.

SELECT [TO], [SYSTEM]
FROM TOwWildcard
WHERE [TO] In (SELECT [TO] FROM [TOwWildcard] As Tmp GROUP BY [TO] HAVING Count(*)>1 )
ORDER BY [TO];

No comments: