You are on page 1of 14

MS-ACCESS

QUERIES
What is a Query ?
A query is like a simple question that is asked to find specific
information from the database.
For example, which students are scoring above 85% marks?
Which students live in sector 14, Vasundhara ?
Queries are made on tables and the result of a query is also
displayed in the form of a table.
MS-Access provides various types of queries :
Select, Parameter, Crosstab, Action Query & SQL.
To enable a query with more than one table to return meaningful results, the two tables
must be linked by a relationship.

In a relational database, relationships enable you to prevent redundant data. For


Relationship
example, if you are designing a database that will track information about books, you
might have a table named "Titles" that stores information about each book, such as the between tables
book's title, date of publication, and publisher. There is also information that you might
want to store about the publisher, such as the publisher's telephone number, address,
and ZIP Code/Postal Code. If you were to store all this information in the "Titles" table,
the publisher's telephone number would be duplicated for each title that the publisher
prints.
A better solution is to store the publisher's information only one time, in a separate
table that we will call "Publishers." You would then put a pointer in the "Titles" table
that references an entry in the "Publishers" table.
Creating queries in the database
using Design View
1. Click on the ‘Create’ tab above
the ribbon and then click on
‘Query Design’.
2. In the ‘Show Tables’ box, select
the tables needed for the query.
You can do this by either double
clicking the name of the table or
single clicking the table name and
then clicking ‘Add’.
QUERY CRITERIA

Query criteria helps you to retrieve specific items from an Access database. If an item
matches with all the criteria you enter, it appears in the query results.
A query criterion is an expression that Access compares to query field values to determine
whether to include the record that contains each value.
Structured Query Language(SQL) is SQL commands are mainly categorized
into four categories as:
the database language by the use of

which we can perform certain


DDL – Data Definition Language
operations on the existing database

and also we can use this language to DQl – Data Query Language

create a database. DML – Data Manipulation Language

DCL – Data Control Language


DDL DML
DDL is Data Definition Language which is used to define data DML is Data Manipulation Language which is used to
structures. For example: create table, alter table are manipulate data itself. For example: insert, update, delete
instructions in SQL. are instructions in SQL.

SELECT INSERT
SELECT(column1, column2…) FROM INSERT INTO table(column1,
table_name column2…)VALUES(value1, value2…)
[WHERE condition]
[ORDER BY column] Example :
Example : Insert into student( “Roll no”, “Marks”)
Select * from “students” Values (15, 80)

UPDATE
UPDATE table_name SET column_name =
value[column_name=value..]
[WHERE condition]
DDL DML
DDL is Data Definition Language which is used to define data DML is Data Manipulation Language which is used to
structures. For example: create table, alter table are manipulate data itself. For example: insert, update, delete
instructions in SQL. are instructions in SQL.

CREATE
DELETE CREATE TABLE table_name
DELETE FROM “table_name” ([column definition])
[WHERE condition] [table parameters]
Example : Example :
Delete from “Student” where “Rollno”=“10” Create table “Library”(Book_No”integer,
“Book_name”varchar(50),
“category”varchar(40))
Reports have three types of sections :

Database Object : Report Header : The Report header appears only


once, at the beginning of the report. The
A report is a summary of the database. It topmost content of the report (such as
is an effective way to organize and company name, address and logo) belong in
the report header. The page header appears
summarize data for viewing and printing.
on every page of the report.
It consists of information obtained from
tables or queries. Detail : The detail section contains most of the
information in the report.

Footer : The page footer appears on every


page. The report footer appears once , at the
end of a report. The page footer section may
contain page number, the report footer section
may contain the conclusion like grand total.
Create a Report with the Report Wizard in Microsoft Access

1.On the Create tab in the Reports group,


click Report Wizard. The wizard starts

2.From the Tables/Queries drop-down list, select the


table (or query) to base the report on. The fields for
the selected table load in the Available Fields list
box.

3.Move the fields to include on the report from


the Available Fields list box to the Selected Fields list
box.
To do so, double-click a field name to move it or
highlight the field name and click >. To move all
fields at once, click >>. Click Next >.
5.In the first drop-down list, select the field to sort records by. By
4.To group records on the report by a
default, records will be sorted in ascending order by the field you
particular field, highlight the field in the list
select.
box and click >.
If you want to sort in descending order, click the Ascending button to
change its label to "Descending".
7.
1.Enter a title for the report.
6.In the Layout field, select the format of the report.
Your options are "Stepped", "Block", and "Outline". 2.Select an option for the view you want to open the report in. Your
options are:
•Preview the report (opens in Print Preview mode).
•Modify the report's design (opens in Design view).
8. Click Finish. The report loads in the view you selected.

Print Preview Design View

You might also like