mark dixon page 1 02 – queries: query by example

12
Mark Dixon Page 1 02 – Queries: Query by Example

Post on 21-Dec-2015

226 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 1

02 – Queries: Query by Example

Page 2: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 2

Questions: Databases

• Consider the following table:

a) How many records does it contain?

b) How many fields does it contain?

9

6

Page 3: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 3

Session Aims & Objectives• Aims

– Introduce you to queries

• Objectives,by end of this week’s sessions, you should be able to:

– create a query using 'query by example' to:• extract a subset of records and fields from a database

table

Page 4: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 4

Creating Queries: New Query• Select the database window

• Select queries option

• Double click on Create Query in Design view

Page 5: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 5

Creating Queries: Add Table

• Click Add button

• Click Close button

Page 6: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 6

Creating Queries: Add Fields

• Drag field names into query

Page 7: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 7

View you Query

• Click View button

Page 8: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 8

Return to Query Design

• Click View button again

Page 9: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 9

Modify your Query

• Type in criteria

Page 10: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 10

Criteria

• Massive variety – very powerful:> greater than

< less than

= equal to

>= greater than or equal to

<= less than or equal to

<> not equal to

Like "*or*" * means any text (i.e. contains "or")

Page 11: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 11

Tutorial Exercise 1: Plants database• LEARNING OBJECTIVE:

to understand table, field, and record, so that you can create your own database with a single table containing several fields and records using MS Access

• TASK: Create the plants database (shown in earlier slide).

Page 12: Mark Dixon Page 1 02 – Queries: Query by Example

Mark Dixon Page 12

Tutorial Exercise 2: Plants database• LEARNING OBJECTIVE:

to understand queries, so that you can create your own query that displays selected fields and records from a table using MS Access

• TASK 1: Create the query (shown in earlier slide).• TASK 2: Experiment with Show, Sort and Criteria combinations