What is an SQL query and when would you use one?

What is an SQL query and when would you use one?

An SQL query is a query you create using an SQL statement. Examples of SQL-specific queries are the union query, pass-through query, data-definition query, and subquery.

This topic provides examples of:

Union query

Pass-through query

Data-definition query

Subquery

Union query

This type of query combines fields (columns) from one or more tables or queries into one field or column in the query's results. For example, if you have six vendors that send new inventory lists each month, you can combine these lists into one result set using a union query, and then create a make-table query based on the union query to make a new table. For examples of union queries, click .

For information on creating a union query, click .

Return to top

Pass-through query

This type of query sends commands directly to ODBC databases, such as Microsoft FoxPro, using commands that are accepted by the server. For example, you can use a pass-through query to retrieve records or change data.

For information on creating a pass-through query, click .

Return to top

Data-definition query

This type of query creates, deletes, alters tables, or creates indexes in a database , such as Microsoft Access or Microsoft FoxPro tables.

For information on creating a data-definition query, click .

Return to top

Subquery

This type of query consists of an SQL SELECT statement inside another select query or action query. You can enter these statements in the Field row of the query design grid to define a new field, or in the Criteria row to define criteria for a field. You can use subqueries to:

For information on creating a subquery, click .

Return to top