How to Create a SQL Query in Microsoft Access

by Contributor

SQL queries use Structured Query Language (SQL), a standard scripting language, to make requests from databases. You can use four types of SQL queries in Access 97: union, pass-through, data-definition and subquery.

Creating a Subquery

Step 1

Create a new select or action query. (See Related eHows for instructions.)

Step 2

In Query Design view, add the desired fields to the design grid.

Step 3

To use a subquery to define criteria for a field, type a SQL select statement in the Criteria cell. Set the select statement in parentheses. If you're using a subquery to define a Field cell, type a select statement in the Field cell instead.

Step 4

Rename the fields if desired.

Click the View button to see the results.

Creating a Union Query

Step 1

Open the Database window.

Step 2

Click the Queries tab. Click New. The New Query dialog box opens.

Step 3

Click Design View. Click OK. The Show Tables dialog box appears.

Step 4

Don't add any tables. Click Close.

Step 5

Click on the Query menu, then click on SQL Specific. Select Union.

Step 6

Enter SQL select statements. Add the Union operation if you don't want duplicate records or the Union All operation if you do want duplicate records.

Click View to see your results.

Creating a Pass-Through Query and Creating a Data-Definition Query

Step 1

Follow steps 1 through 4 above to create a pass-through query.

Step 2

From the Query menu, click on SQL Specific and then on Pass-through.

Step 3

From the View menu, select Properties. The query property sheet appears.

Step 4

Set the ODBCConnectSTR property to define information about the database you intend to connect to. You will need information about the server.

Step 5

Type your pass-through query in the SQL Pass-through Query window.

Step 6

Click Run on the toolbar. If your query returns records, click View instead.

Step 7

Follow steps 1 through 4 above to create a data-definition query.

Step 8

Open the Query menu and select SQL Specific, then click on Data Definition.

Step 9

Enter the SQL statement for your query. You can enter Create Table, Alter Table, Drop Table and Create Index.

Click the Run icon on the toolbar.


  • Subqueries are made up of a SQL select statement located inside another select query or action query. Subqueries allow you to test to find out whether something exists or does not exist, to find values in the main query that are equal to, greater than or less than values in the subquery, or to create nested subqueries (that is, subqueries within subqueries).
  • Union queries allow you to combine records from two or more tables.
  • Select statements that you can use are Select, From, Where, Group By, Having, Order By, and With Owner Access Option.
  • Pass-through queries retrieve records or change data on networked (ODBC) databases.
  • Data-definition queries create or modify database objects like those found in Microsoft Access or in Microsoft SQL Server tables.

Items you will need

  • Microsoft Access

Video of the Day

Brought to you by Techwalla
Brought to you by Techwalla

More Articles