Introduction to Queries/ What is a Query? Why Use Queries?

Introduction to Queries/ What is a Query? Why Use Queries?


What is a Query?

In the strictest sense, a query is a way to answer questions about the data in your tables. It allows you to retrieve items in a database that meet a set of criteria that you specify. However, within the realm of modern databases, a specialized form of a query can also be used to:

  1. Define database objects
  2. Perform Calculations
  3. Make new tables
  4. Append, delete, or update records
  5. Produce data summaries

Access contains some other features that are not strictly classified as queries but they can be used to achieve query-like results. These are sorting and filter. Sorting was covered in the Introduction to Access workshop and we will discuss filters today before we tackle actual queries. Wildcards (*,?,NULL) will also work for filters and queries.

Why Use Queries?

In most cases, the real reason for using a database to store data records is so they can be retrieved using some criteria that is specified interactively, Since this is the definition of a query, we could logically assume that queries are the main reason for using a database. Access gives you a great deal of flexibility and power with queries. You can use them to:

#How to apply Driving License in Assam?
#How to Renew Driving License in Assam?
#How to Apply for a Duplicate licence in Assam?

  1. Choose fields: You can select the exact fields needed to satisfy the query. You do not have to include all of the fields of a record in a query.
  2. Choose records: You can select records from a table based on a specified criteria.
  3. Sort records: You can view the results of the query in a specified order.
  4. Access multiple tables: You can select data from several different tables and place the results in a single dynaset, You can even access data from other database management systems.
  5. Perform calculations: You can add new fields in the dynaset that contains the results of Calculations involving other fields.
  6. Provide data source: You can use a query as a source of data for forms, reports, and other queries.
  7. Update data: You can update, delete, or append a group of records in one step. You can even create a new table that includes some or all of the records from an existing table or tables.

Using a Query

Microsoft Access contains a number of query wizards or you can create one from scratch using a form of Query by Example-where you specify the retrieval criteria by placing typical values in columns. You can then treat the columns of sample data as an example for the query. This is the exact same concept that we used for the advanced filter earlier. However, a query is more complex than a filter, since it can:

  1. Apply to multiple tables
  2. Select individual fields instead of full records
  3. Be saved and reused

Type Of Queries

1. High Courts and Subordinate Courts.

Query Type Description
Select Query A select query is used to view, analyze, or update the data in one or more tables. It is the most common type of query In Access and it is very similar to the previously discussed filter.
Crosstab A crosstab query is used to present the data in rows and columns like a spreadsheet. It can summarize large amounts of data in an easy-to-read format and it blends well with reports and charts.
*Make Table Query Creates a new table from a dynaset. It can be used to make table backups, to archive old data, or to create an extract of a table for exporting.

  • Update Query
Lets you make global changes to data in one or more tables. Allows you to enter one set of changes that could be posted to many records with minimal effort.
  • Append Query
Allows you to add records to the end of a table. It can be used to merge tables together by appending one table to the end of another.
  • Delete Query
Deletes a group of records from one or more tables. Could be used in conjunction with the Make Table query to delete archived records from a table after an archive table was created and filled.
  • Union Query
A union query is used to combine the matching fields from two or more tables.
  • Pass-Through Query
A pass-through query is used to send commands to a SQL database.
  • Data Definition Query
A data definition query creates, changes, or deletes tables in a Access database using SQL statements.

These are action queries. When these queries are run, design or content changes are made to the database in some manner.

Post a Comment