0% found this document useful (0 votes)
116 views16 pages

CHP 11 - Advanced Queries

Using SQL View allows you to edit existing queries using SQL. Creating update queries allows you to update multiple records at once by specifying the field and value to update. Creating delete queries allows you to delete multiple records at once by specifying criteria. Creating additional/calculated fields in a query allows you to display new fields that are calculated from existing fields in the table but do not exist in the actual table.

Uploaded by

westlifehk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
116 views16 pages

CHP 11 - Advanced Queries

Using SQL View allows you to edit existing queries using SQL. Creating update queries allows you to update multiple records at once by specifying the field and value to update. Creating delete queries allows you to delete multiple records at once by specifying criteria. Creating additional/calculated fields in a query allows you to display new fields that are calculated from existing fields in the table but do not exist in the actual table.

Uploaded by

westlifehk
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

11.

1 Using SQL View

Suppose we have the below query created.

We can edit the query by using the SQL View.


1) Click
View

2) Select SQL
View
You can now edit the query with
SQL

11.2 Creating Update Queries

Suppose we have the following data in the User table.


We want to increase the User Quota for every user; it is exhausting to edit the

value for each user one by one manually. Therefore we can create an update

query to do for us.

First we create a query.

Then we go to the Design View of the query.


Click
Update
These are the
different types of
queries

You will find the lower part of the query will become like this

Enter [UserQuota]+10 into the “Update To:” field.


Click
Run
Click Yes to
execute

You don’t have to save the query because it is one-use only.

Go to the User table and you can see the quota for each user has increased by

10.
11.3 Creating Delete Queries

Suppose we have the following data in the User table.

We want to delete any user account whose Penalty has reached more than

$100.

We can then create a delete query to do it.

First, we need to create a search query.


This time we are here to create a delete query, so we click the Delete in the

Design View..

The lower part of the query will become like this:


Enter >100 into the Criteria field of UserPanelty.

Click .

Click Yes to execute the delete


query
You don’t have to save the query.

You can open the User table and you can see user with Penalty larger than 100

is deleted.
11.4 Creating

Additional/Calculated Fields

Suppose we have the following data in the User table.

And we have select query like this:


In Access 2008, we can add calculated fields in the query which do not exist in

the table.

Now we want to add a TotalPenalty to add up the BookPenalty and

MultiMediaPenalty.

Go to the Design View of the query.


Enter “Total Penalty: [BookPenalty]+[MultiMediaPenalty]”
into the Field

Total Penalty:
[BookPenalty]+[MultiMediaPenalty]
Total Penalty: [BookPenalty]+[MultiMediaPenalty]

Field Name Add up BookPenalty and MultiMediaPenalty

Save it and Run it, you will see the result.

You might also like