Sie sind auf Seite 1von 36

IMPORTANT NOTES

Before you could take prints of this PRESENTATION make sure


you update few details like your NAME, ROLL NUMBER, AND
YOUR TEACHERS NAME etc.
One more thing I have removed all the background images
because in case you guys take B & W print-outs it would be
horrible.. So its a recommendation take prints in this format
and in your VIRTUAL PRESENTATION you guys can add up all
the ANIMATIONS & OTHER STUFF to make it look good so that
your faculty knows that you know it all
Last but not the least for any POPAT please dont blame me.
For any other issues send me a PM..
Regards
Vikas.(,)

ACKNOWLEDGEMENT
I express my gratitude and heartily thanks
to our respected faculty Mr. Jitender sir,
Mr. Alok sir and Mr. Vinay sir for their
guidance and constant support towards
the preparation of this project, moreover
without all the mentioned names this
project would not have seen the light for
the evening.

QUERY IN
MICROSOFT
OFFICE ACCESS

QUERY??
Introduction
As tables grow in size they can have hundreds of thousands of records, which makes it
impossible for the user to pick out specific records from that table. Queries were designed to
combat this problem. With a query you can apply a filter to the table's data, so that you only
get the information that you want.
The tricky part of queries is that you must understand how to construct one before you
can actually use them. This lesson will guide you through the basics of making a couple very
simple Access queries.

Definition
Queries are the primary mechanism for retrieving information from a database and
consist of questions presented to the database in a predefined format.

In Simple Words
A query is a set of instructions that you can use for working with data. You run a query
to perform these instructions. In addition to returning results which can be sorted, grouped,
or filtered a query can also create, copy, delete, or change data.

Queries Object
In MS Access we can use queries to extract
information (data) from one (or more) tables (or from
other queries). The information we retrieve can be
limited by the definition of our query.
In access queries are database objects that can be
used to retrieve a subset of data. Unlike filters queries
can be saved and used as a data source for other ms
access objects such as reports, forms or data access
pages.

TYPES OF QUERIES
1) Select Query.
2) Update Query.
3) Append Query.
4) Delete Query.

HOW TO USE QUERY?


Choosing A Table To Query.
Before we can create a query we have to navigate to the Query Tab in
our Access database. Select Queries from the Objects Pane.

CURRENT DATABASE THAT


WE HAVE

Although we could use the Wizard, we will guide


through the process of creating an Access query with the
"Design view".
Creating a query by using Wizard gives us an option to
run Automated and Pre-defined set of instructions to create
and run a query.

CREATING QUERY BY USING WIZARD

Continuing Query In Design View


1)
2)

Double-click Create Query in Design view


Add the table.

3)

Our Query window should now have the table added to it.
Now we in the setup process for making a query. Every time we make a query we have
to first choose which table(s) we want to select data from. Currently, our database only has 2 table,
so we don't have a lot of choices here.
The table(s) added will appear like the boxes encircled.

Inserting Field For Setting up Query

The insertion of fields can be done by using drop-down box appears in fields and by dragging and
dropping directly from the tables to query field.

1) SELECT QUERY
The select query is the simplest type of query and because of that, it is also
the most commonly used one in Microsoft Access databases. It can be used to
select and display data from either one table or a series of them depending on what
is needed.
In the end, it is the user-determined criteria that tells the database what the
selection is to be based on. After the select query is called, it creates a "virtual"
table where the data can be changed, but at no more than one record at a time.

Select query can be used to


1)
2)
3)
4)
5)

view subset of records


Retrieve data form one (or more) tables
Display the results in a datasheet
update the records from within the datasheet
group records and do calculations (sum, average, counts, totals, etc).

By default Microsoft Office Access Always Opens Select Query


So We Need Not Choose It Particularly. However Select Query
can be chosen from Query Tab.

Firstly we need to insert (populate) and select all the fields on which Select
Query needs to be run.

Then in Criteria we should choose the basis on which Select Query is to be


performed.

Run A Query

Click Run

Result Window

In Case Select Query Needs To Be Run On 1 Table With 2 Different Filters On


Different Fields Then The Option Of OR Can Be Used And Desired Result Can Be
Obtained.

Result Window When Criteria Is Used Along with


Or

2)

UPDATE QUERY

Using update query you can make global changes to a group of records in one or more
tables. For example, you can raise grades by 10 percent for all Students (or a subset of students).
An Update query is a query that makes updates to many records at the same time.

Keep In Mind About The


Formula.
While Applying The Formula To Any Field
Following Things Should Be Followed.
1) Formula Should Be Put-in To Update-to.
2) Table Name! (An Exclamation Sign Should Be Given After Table Name
For Reference) i.e. Employee Salary Details Is Above Example.
3) The Name Of Base Field For Updating i.e. Basic_Pay
4) Then The Calculative/Mathematical Formula i.e. *10/100
{Where * Denotes Multiply & / Denotes Division}
5) Formula Should Be Put In Without Any Spaces.

After clicking Update Query From Query Tab We Need To Click Run & On The Confirmation
Dialogue Box Click Yes So That The Table Gets Updated Which Can Be Saved Then Accessed
From The Table Manu.

Result Window

3) APPEND QUERY
Append Query is used to add records/group of records from one or
more tables at the end of an existing table. Append Queries are especially
useful for adding old records to the end of a table.
For example, suppose that we drop Students form one Class1and
register them for Class2. We can append records into the Class2.

1) Since in Select Query we can only get the data we have Selective
Approach.
2) An Update query is used for calculation & replacing function.
3) But if there are more than one database exists and we want to merge both
of them then Append Query is used to join or merge the databases.

Existing Database We Have

Now We want to merge both of the above shown table into one.
To execute this desire we will perform Append Query

How To Run Append Query


1) Firstly, we must choose
Query From The Database.
2) Then, we need to choose
the option Create Query
In Design View. (Either
WIZARD or DESIGN
VIEW can be used).
3) Add the table which we
would like to append
another tables data or table
and insert required fields.
4) Choose Append Query
from the Query Tab.
5) Append Windows which
comes up next select the
Table which needs to be
appended or updated.

Click Run

Query Confirmation Box

Result Window
Data Has Been Successfully Updated To The Table Chosen.

4) DELETE QUERY
A Microsoft Office Access Delete Query deletes records from a single
database table or database tables. Of all of the different action queries available in
Microsoft Access (Select Queries, Append Queries, Update Queries and Delete
Queries) the delete query is one of the most dangerous. Unlike the others
mentioned, the Microsoft Access delete query will remove records from your tables
permanently and forever.
As with the other types of action queries, the delete query will work with a
group of records that meet a specified criteria that you apply. You can use the delete
query to remove all records or only records that meet the defined criteria.

In Simple Words:
Delete Query allows us to delete a group of records that meet specific search
criteria in bulk. The procedures for setting up a Delete Query depends on whether
we are deleting records from a single table or from multiple tables that are involved
in a one-to-many relationship

How To Run Delete Query


Existing Table With 10 Records

1) Firstly, we must
choose Query
From The
Database.
2) Then, we need to
choose the option
Create Query In
Design View.
(Either WIZARD
or DESIGN
VIEW can be
used).
3) Add the table in
which any specific
desired data needs
to be deleted.

Table With Desired Fields Inserted To It


For Running Delete Query

Criteria Has Been Set For


Delete Query To Run

Delete Query Confirmation Dialogue Box.


We need to click on yes so that Delete Query comes into picture and delete
the desired records/data.

Result Window

FINAL OUTPUT. THE TABLE NO LONGER HAS RECORDS FOR FARISH


AND HAS ONLY 9 RECORDS

Than
k You

Das könnte Ihnen auch gefallen