MS Access - Queries+1
MS Access - Queries+1
PROFESSIONAL STUDIES
MICROSOFT ACCESS
QUERIES
Learning objectives
Define and understand database queries
Creating and designing database queries in Microsoft
Access
Saving queries
Introduction to database queries
A database query is a request for data or information from a
database. It allows users to retrieve, manipulate, or analyze data stored
in a database. Queries are typically written in a specialized language,
such as SQL (Structured Query Language), which communicates
with the database to perform specific tasks.
Functions of a Query
Retrieve Data: Extract specific data from one or more database
tables. Example is "Show all customers from New York.“
Update Data: Modify existing records in the database.. Example:
"Change the phone number for customer ID 123.
" Insert Data: Add new records to the database. Example:
"Add a new product to the inventory."
Delete Data: Remove records from the database. Example: "Delete
orders placed before 2020."
Types of Queries
1. Select Query: Retrieves data from one or more tables. SQL Example: SELECT
* FROM Customers WHERE City = 'New York';
2. Action Query: Modifies data in the database (e.g., INSERT, UPDATE,
DELETE).. Example: UPDATE Products SET Price = Price * 1.1 WHERE
Category = 'Electronics';
3. Parameter Query: Prompts the user for input to customize the results.
Example: "Enter a city name to view customers."
4. Cross-tab Query: Summarizes data in a table format (e.g., totals by month).
5. SQL Query: Directly written in SQL for advanced operations.
Components of a Query
1. Table: The source of the data.
2. Fields (Columns): Specific data points to retrieve or modify.
3. Criteria: Conditions that determine which records are affected or returned.
4. Operators: Define the type of operation (e.g., =, <, >, AND, OR).
In Microsoft Access, queries can be created using:
1. Query Design View: A graphical interface where you select tables
and define criteria.
2. SQL View: Where you write SQL code directly.
Creating queries in MS Access 2021
1. Select Create > Query Wizard .