An Action Query is a query that changes data in a database. It can add records, update existing records, delete records, or create a new table from selected data. Action Queries are useful for performing operations on multiple records at once.
A Select Query displays records without directly changing the data in the table. An Action Query performs an operation that changes data or creates a table.
| Query Type | Purpose |
|---|---|
| Update Query | Changes existing field values. |
| Append Query | Adds records to an existing table. |
| Delete Query | Deletes records from a table. |
| Make-Table Query | Creates a new table from query results. |
These four query types are the main action queries commonly taught in Microsoft Access.
An Update Query changes the values of existing records. For example, you can increase course fees or update the course name for selected students.
| StudentID | StudentName | Course | Fees |
|---|---|---|---|
| 101 | Amit | ADCA | 8000 |
| 102 | Priya | ADCA | 9000 |
| 103 | Rahul | Tally Prime | 4000 |
UPDATE Students
SET Fees = Fees + 1000
WHERE Course = "ADCA";
This query increases the Fees value by 1000 for every student whose Course is ADCA. Other students remain unchanged.
An Append Query adds records to an existing table. It is useful when transferring records from a temporary table or an older table into a main table.
Suppose you have a table named NewStudents
containing records that need to be added to
Students.
INSERT INTO Students
(StudentID, StudentName, Course, Fees)
SELECT
StudentID, StudentName, Course, Fees
FROM NewStudents;
This query appends the selected records from NewStudents to Students.
A Delete Query removes selected records from a table. It deletes entire records, not just the contents of one field.
DELETE FROM Students
WHERE Course = "Tally Prime";
This query deletes every record from Students where the Course is Tally Prime.
Before deleting records, run a Select Query using the same condition:
SELECT *
FROM Students
WHERE Course = "Tally Prime";
Check the returned records. If they are exactly the records you intend to remove, create and run the corresponding Delete Query.
A Make-Table Query creates a new table using the results of a query. It is useful for preparing an archive, extracting a subset of records, or creating a separate working table.
SELECT *
INTO ADCAStudents
FROM Students
WHERE Course = "ADCA";
This query creates a new table named ADCAStudents containing the records selected from Students.
Microsoft Access lets you convert a query into an action query using the Query Design tab.
| Action | Design Tab Option | Result |
|---|---|---|
| Update values | Update | Changes existing records. |
| Add records | Append | Adds records to a destination table. |
| Remove records | Delete | Removes matching records. |
| Create a table | Make Table | Creates a new table from query results. |
The available options may vary slightly depending on your version of Access and the query design.
Criteria control which records an action query affects. Always use a specific condition when you intend to update, append, or delete only a subset of records.
UPDATE Students
SET Fees = 12000
WHERE StudentID = 101;
This query sets the Fees value to 12000 for the student whose StudentID is 101.
DELETE FROM Students
WHERE StudentID = 104;
This query deletes the record for StudentID 104. Check the ID before running the query.
INSERT INTO ADCAArchive
(StudentID, StudentName, Course, Fees)
SELECT StudentID, StudentName, Course, Fees
FROM Students
WHERE Course = "ADCA";
This query appends only ADCA student records to the existing ADCAArchive table. The destination table must have compatible fields.
Action Queries are powerful, but their effects should be checked carefully before execution.
Create a Students table with StudentID, StudentName, Course, and Fees fields. Insert at least ten sample records.
Goal: Understand Update, Append, Delete, and Make-Table Queries and use them safely.
1. Which query changes existing records?
2. Which query adds records to an existing table?
3. What can happen if a Delete Query has no WHERE clause?