Upload
oswin-bradley
View
215
Download
0
Embed Size (px)
Citation preview
© Boardworks Ltd 20102 of 12
Teacher’s notes included in the Notes Page
Flash activity. These activities are not editable. Web addresses
Icons key: For more detailed instructions, see the Getting Started presentation
Functional Skills check
Student task accompanies this slide Printable activity
This lesson will cover:
Basic sorting in a database.
Creating a basic query.
Creating and using advanced queries.
© Boardworks Ltd 20103 of 12
Sorting and queries
Learning to sort and use queries in databases is incredibly useful as it can allow you to pinpoint the exact data you require.
Can you think of examples of where this is used?
© Boardworks Ltd 20104 of 12
Right-clicking on one of the field headings and then choosing Sort Ascending will put the data in ascending alpha-numerical order.
Basic sorting
Databases are extremely useful as they allow you to create tables of related data which can then be searched and sorted as needed.
Alternatively, you can highlight a field andclick on either of these icons on the toolbar.
© Boardworks Ltd 20105 of 12
Queries
Databases are used for searching and sorting vast quantities of data and producing results that match criteria. To search or sort a database in this way requires the creation of a query.
Select Queries from the Objects menu. Youcan then choose to use the Wizard or Createquery in Design view.
When you are creating queries in design view, you will be able to select sorting options for multiple fields.
To create a query:
You can also save queries and produce a reportwith the data you have obtained.
© Boardworks Ltd 20106 of 12
Creating queries
The top line of the query specifies the fields to be displayed.
The second line specifies which table will providethe data.
The third line selects if the data is to be sorted inascending ordescending order.
Remember to tick the show boxes or your data will not be displayed.
This query has been set up to sort by age, but within each agegroup the results are to be sorted alphabetically by surname.
© Boardworks Ltd 20107 of 12
Advanced queries
Database queries really come into their own when you wantto put together advanced searches.
Imagine you had a database of valued customers. What ifyou wanted to find all the customers under thirty, living inLondon who spent over a £1,000 in the previous year.
This would take you a long time to find on paper reports, butwith a database query it can be done very simply.
Table name Customersunder 30
Livingin London
Spent over£1,000
© Boardworks Ltd 20108 of 12
Advanced queries
Entering data into the criteria box allows you to be very selective about what data is returned.
To help with this you can use logical and relational operators.
Logical operators (AND, OR and NOT) help to create logic statements for queries.
Relational operators (=,<,>,=,<=,>=) help to constructrange statements.
A forename search for “Pete” OR “Peter” will return results for anyone called Pete or Peter.
Example
An age search for >=14 AND <= 18 will return all the records with ages between 14 and 18.
Example