Creating and running SQL queries in MS Access


The capability of MS Access as a research data management tool can be appreciated during the creation and running of SQL queries. The manipulation of data from a single table, and the merging of data from different tables, makes the database versatile in managing the research data without compromising the data integrity.

There are different ways on how to make queries in MS Access. But using a SQL query is a more direct approach. It is like using a template to select particular columns and make calculations.


The SQL query format:

SELECT <list of column names>

FROM <table name>

WHERE <condition to select rows>

ORDER BY <column names for sorting>; 


The following are the steps on how to create and run a SQL query in MS Access:


1. Click on Queries, and double-click on the Create query in Design view.



2. Close the Show Table pop-up window.



3. The query in Design View needs to be switched into SQL View. There are two ways to turn it into SQL View.


A. Right-click the top of the query window and select SQL View, or,



B. Simply click on the SQL View button.



4. A query window will pop-up. This is the area to type the SQL query.

  • Here is an example of a selection query. The short heavy men are selected. The fields to SELECT are rseqn, ethn, sex, age, weight and height. These fields are selected FROM the nhanes table. The condition for selection is WHERE the respondent is Male, weighs more than 129 kg and stands higher than 169 cm. The sorting is ORDERED BY ethn and age in descending order. For a detailed discussion in writing SQL queries, click here.



5. To run the SQL query, Save it and click on the Image:access_sql_run.jpg icon.



6. The SQL query result will appear in Datasheet View.


Last modified January 9, 2008 4:07 am