Write SQL Statements in Microsoft Access

Access is database management software. It is used for keeping and intelligently storing data and tables so that it can be fetched quickly whenever required by any front end application. Access provides its own front end but widely serves as backend data storage for many applications. All the reporting, input and output of the data is done by the frontend of the application and data is stored, fetched and saved in Microsoft Access. On the other hand SQL is a technique to access the records from a database which support SQL queries and understand the SQL language and the query syntax. SQL command or query is a command which fetched out filtered information from any compatible database. In this section we will discuss how to run SQL queries in Microsoft Access to fetch our information from its database. SQL stands for Structural Query Language and works only on databases. It is designed to work on databases and is capable of inserting, modifying, deleting, adding, and displaying data records from a database. With this language you can fetch data from many tables at the same time based on your requirement. For example you can fetch the records of all the students of classes one to ten, who live in the same city, have the same surname and, have the same month of birth. This was just an example to show how SQL can do logical comparisons in fetching data from tables provided you have the information present in your database.

Understanding or creating a SQL query cannot be done without proper knowledge of SQL. SQL is a complete study in itself and is widely used and accept query language in these days. These statements can be coded in any application frontend to do a specific job by a click of button. Let us see how to incorporate SQL in Microsoft Access.

Open Microsoft Access and open the database on which we would be running the SQL query. In the Database window click on Queries button under the Object button. When you get the Query window double click on the Create Query option. Make sure that you are in the Design View in Access. This will give you the Show Tables box which you can close without selecting any tables from the current database. Now click on the SQL view button in the toolbar. Type “SELECT” and press enter. SELECT is a SQL command for selecting the database on which the rest of the commands will work. When you Run the SELECT command it will select all the columns of the database’s table and now type “FROM” and the table name from which you want to fetch the information using the SQL query. For example type “FROM Students” (assuming Students is a table in the current database). Now type the entire query and click on Run. Query depends upon your data and the fields present in the table. Query can be based on logical statements or on the values of the data fields. This is how you can run SQL queries inside Microsoft Access program.

Leave a Reply

Your email address will not be published. Required fields are marked *