18
DAY 16: ACCESS CHAPTER 2 Tazin Afrin [email protected] October 10, 2013 1

Day 16: Access Chapter 2

  • Upload
    harsha

  • View
    45

  • Download
    1

Embed Size (px)

DESCRIPTION

Day 16: Access Chapter 2. Tazin Afrin [email protected] October 10 , 2013. objectives. Single table query Multi-table query. Single table queries. Which customer currently has a balance over $5000? Create a query - PowerPoint PPT Presentation

Citation preview

Page 1: Day  16: Access Chapter 2

DAY 16:ACCESS CHAPTER 2

Tazin [email protected] 10, 2013

1

Page 2: Day  16: Access Chapter 2

2

OBJECTIVES

• Single table query• Multi-table query

Page 3: Day  16: Access Chapter 2

3

SINGLE TABLE QUERIES

• Which customer currently has a balance over $5000?– Create a query

• A query enables you to ask questions about the data stored in a database.

• Need reference of table– For previous question refer Account table

Page 4: Day  16: Access Chapter 2

4

QUERY DESIGN VIEW

• Query Design view enables you to create queries; the Design view is divided into two parts – – the top portion displays the tables– the bottom portion (known as the query

design grid) displays the fields and the criteria.

Page 5: Day  16: Access Chapter 2

5

SINGLE TABLE QUERY

• Create in two ways – – Simple query wizard:

• provides dialog boxes to guide you through the query design process.

• helpful for users who are not experienced.– Query design tool:

• For more advanced users• Provides the most flexibility

Page 6: Day  16: Access Chapter 2

6

QUERY DATASHEET• Display the results of the query.• Query’s datasheet looks and acts like a table’s datasheet• Usually a subset of the records from the table. • Only shows the records that match the criteria.• Allows you to enter a new record, modify an existing

record, or delete a record. • Any changes made in Datasheet view are reflected in the

underlying table.• Caution: Changes Made to Query Results Overwrite

Table Data

Page 7: Day  16: Access Chapter 2

7

SINGLE – TABLE SELECT QUERY

• A select query displays only the records that match the criteria entered in Design view.

• Create -> Queries -> Query Design• Show Table Dialog Box appears• Select table• Add query

Page 8: Day  16: Access Chapter 2

8

USE QUERY DESIGN VIEW

• Consists of two parts:– The top portion contains tables with their

respective field names. – The bottom portion (known as the query

design grid) contains columns and rows. • Field row• Table row• Sort row• Show row• Criteria row

Page 9: Day  16: Access Chapter 2

9

WILDCARD• A wildcard is a special character that can

represent one or more characters in the criterion of a query.

• * mark– Represents one or more characters– If name start with Sm search by Sm*– S*nd will return Sand, Stand, or StoryLand.

• ? mark– Stand for a single character– H?ll will return Hull, Hill, or Hall etc.

Page 10: Day  16: Access Chapter 2

10

COMPARISON OPERATORS• A comparison operator can be used in the criteria

of a query.• Such as –

– equal (=)– not equal (<>),– greater than (>)– less than (<)– greater than or equal to (>=)– and less than or equal to (<=)

• Query for salary >5000

Page 11: Day  16: Access Chapter 2

11

NULL

• Null is the term Access uses to describe a blank field.

• Example:– Is Null

• For an Employee field in the Customers table when the customer has not been assigned a sales representative.

– Is Not Null • For the ShipDate field; a value inserted indicates the

order was shipped to the customer.

Page 12: Day  16: Access Chapter 2

12

ESTABLISH LOGICAL CRITERIA

• The AND logical operator returns only records that meet all criteria.

• The OR logical operator returns records meeting any of the specified criteria.

• The NOT logical operator returns all records except the specified criteria.

Page 13: Day  16: Access Chapter 2

13

QUERY OPERATION

• Copy a query• Run a query

Page 14: Day  16: Access Chapter 2

14

MULTI-TABLE QUERY

• A multi-table query contains two or more tables.

• Enables you to take advantage of the relationships that have been set in your database.

• Related tables should already be established when you create a multi-table query.– Related tables are tables that are joined in a

relationship using a common field.

Page 15: Day  16: Access Chapter 2

15

MORE OPERATIONS

• Add additional tables• Get answers using query• Modify multi-table query• Add and delete fields

Page 16: Day  16: Access Chapter 2

16

COMMON MISTAKE• Use tables in query who are not joined.

– Results in more rows than usual– For example, If we create a query on Customer table and

Branch table but forget to join them.– Suppose Customers table contains 11 records, and the

Branch table contains 5 records. – Since Access does not know how to interpret the unrelated

tables, the results will show 55 records –every possible combination of customer and branch (11*5).

• When add new table, create relationships.• Temporary join line in query will not create an actual join

line between tables.

Page 17: Day  16: Access Chapter 2

17

NEXT CLASS

• Access Chapter 3– Order of operations.– Create a calculated field.– Create expressions.– Use built-in functions.– Perform date arithmetic.

Page 18: Day  16: Access Chapter 2

THANK YOU LOG OFF