How to Create a SQL Query in Microsoft Access
Posted by JanWan
Last Updated: March 11, 2012

Microsoft Access

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.


Microsoft Access

Creating a Subquery

  • 1

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

  • 2

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

  • 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.

  • 4

Rename the fields if desired.

  • 5

Click the View button to see the results.

Creating a Union Query

  • 6

Open the Database window.

  • 7

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

  • 8

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

  • 9

Don't add any tables. Click Close.

  • 10

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

  • 11

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.

  • 12

Click View to see your results.


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

  • 13

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

  • 14

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

  • 15

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

  • 16

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

  • 17

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

  • 18

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

  • 19

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

  • 20

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

  • 21

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

  • 22

Click the Run icon on the toolbar.


Reminds me of I.T back in high school