Writing Simple Queries in Access

Slides:



Advertisements
Similar presentations
Concepts of Database Management Seventh Edition
Advertisements

Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
Querying a Database Microsoft Office Access 2003.
Access Presentation 3 By: Rasagnya Waghray Ali Murtuza.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Microsoft Access Database software. What is a database? … a database is an organized collection of data. A collection of data of similar information compiled.
Introduction to Database Systems
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
Concepts of Database Management, Fifth Edition
Introduction to Access By Mary Ann Chaney and Alicia Harkleroad.
ASP.NET Programming with C# and SQL Server First Edition
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
CS&E 1111 AcQueries Writing Simple Queries in Access Displaying on specific data fields Filtering data using criteria Objectives: Learn how to use the.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
CS&E 1111 AcQueries Querying in Access Sorting data Aggregating Data Performing Calculations Objectives: Learn how to use the Access Query Design Tool.
CS&E 1111 AcInnerJoins Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data.
Introduction to Microsoft Access Overview 1. Introduction What is Access? A relational database management system What is a Relational Database? Organized.
Database Queries. Queries Queries are questions used to retrieve information from a database. Contain criteria to specify the records and fields to be.
Microsoft Access 2010 Building and Using Queries.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Microsoft ® Access ® 2010 Training Create Queries for a New Database If a yellow security bar appears at the top of the screen in PowerPoint, click Enable.
Concepts of Database Management Seventh Edition
Computer Science & Engineering 2111 Lecture 11 Querying a Database 1.
Introduction to Computers Lesson 10B. home Database A collection of related data or facts.
Introduction to Computers Lesson 10B. home Database A collection of related data or facts.
 Agenda 2/20/13 o Review quiz, answer questions o Review database design exercises from 2/13 o Create relationships through “Lookup tables” o Discuss.
Computer Science & Engineering 2111 Querying a Database 1CSE 2111 Lecture- Querying a Database.
Microsoft Office Illustrated Introductory, Premium Edition Using Tables and Queries.
Computer Science & Engineering 2111 CSE 2111 Lecture Multiple and Compound Criteria in Queries 1 CSE 2111 Lecture-Multiple and Compound Criteria in Queries.
Database Management Systems.  Database management system (DBMS)  Store large collections of data  Organize the data  Becomes a data storage system.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
1 Chapter 3: Customize, Analyze, and Summarize Query Data Exploring Microsoft Office Access 2007.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
Queries Objective 5.02 Understand queries, forms, and reports used in business.
Chapter 1 Introduction to Database. Database Concept Field: a basic data element or attribute of an object Record: a set of fields Table: a set of records.
Microsoft Access Lesson 5 Lexington Technology Center February 25, 2003 Bob Herring On the Web at
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 2 ® Building Queries.
Lesson 4: Querying a Database. 2 Learning Objectives After studying this lesson, you will be able to:  Create, save, and run select queries  Set query.
IST 220 – Intro to Databases
MS Access Forms, Queries, Reports Matt Martin
Database Management Systems II
Querying in Access Objectives: Learn how to use the Access Query Design Tool manipulate data in Access: Sorting data Aggregating Data Performing Calculations.
Microsoft Office Illustrated Introductory, Windows Vista Edition
Introduction to Database Systems
Inner Joins Objectives: Creating Queries with data from Multiple Tables Joining two tables using an Inner Join Referential Data Integrity Cascade Update.
Access Creating a Database
Microsoft Office Illustrated Fundamentals
Access Creating a Database
Access Maintaining and Querying a Database
Database Management  .
Database Vocabulary Terms.
Exploring Microsoft Office Access 2007
Microsoft Office Access 2003
Database Queries.
Tutorial 3 – Querying a Database
Microsoft Office Access 2003
Spreadsheets, Modelling & Databases
Lesson 3 Chapter 10.
Introduction to Access
Databases This topic looks at the basic concept of a database, the key features and benefits of a Database Management System (DBMS) and the basic theory.
Microsoft Office Illustrated Introductory, Windows XP Edition
Shelly Cashman: Microsoft Access 2016
Database Management Systems and Enterprise Software
Presentation transcript:

Writing Simple Queries in Access Objectives: Learn how to use the Access Query Design Tool to obtain specific information by - Displaying on specific data fields Filtering data using criteria

Querying : The process of asking the database for specific information A specific format is used to ask these questions The computer saves the format, not the results which can be generated upon demand (dynaset) We will study the following types of queries: Filtering data using single and multiple criteria Sorting data Grouping and summarizing data Performing calculations on the data

Query Writing queries involves A query is a question about the data in the database Writing queries involves Choosing the required tables Where is your information coming from Choosing the output fields What information do you want to list Choosing the criteria fields What selection criteria do you want to specify -which records to “choose”

Writing a Criterion Criteria is a collection of criterion or conditions: Criterion - an expression that tells the DBMS which records to retrieve Criteria with 2 conditions: List records from category BE with more than 40 units in stock

Consider the following database : Products: Suppliers: Primary Key Foreign Key

Create a list of products by name and the number of units in stock for each CategoryID ProductName Unitsinstock SupplierID ProductID Price No conditions

The resulting dynaset: What happens if we later change the units in stock for Mini-cookies on the Products Table an re-run the query?

List the products & units in stock for category BE CategoryID ProductName Unitsinstock SupplierID ProductID Price Single condition criterion showing ProductName & Units

The resulting dynaset: The data table: The resulting dynaset:

= , <= , >= , <> , < , > Relational operators in a query: = , <= , >= , <> , < , > With Numbers <= 10 values of less than or equal to 10 With Text < “G” text beginning with letters A through F > “Jones” text from Jones through end The appropriate expression is placed in the field where this data if found.

List the product names for products with greater than 40 units in stock CategoryID ProductName Unitsinstock SupplierID ProductID Price You can use relational operators in your criteria

The resulting dynaset: The data table: The resulting dynaset:

List the product names and units in stock for products from the letters M to Z CategoryID ProductName Unitsinstock SupplierID ProductID Price You can use relational operators in your criteria

Wild cards in Criteria: An asterisk * replaces any number of characters: Like “C*” – in Product Name field will select c, Cookie, cake. Like “*cookie*” - in Product Name field will select all records that include the word cookie in the Product Name field A ? replaces a single character Like “B?” – in the Category field will select BE & BA Would the criteria Like “432??” in the zipcode field select a record with the zipcode 43219-7888?

List the product names for products that start with the letter M CategoryID ProductName Unitsinstock SupplierID ProductID Price You can use wild cards in your criteria - just need to type m* the computer will add the syntax Like “...”

For multiple conditions in the same field use Boolean Operators - AND, OR, NOT “BE” Or “BA” >5 AND <10 NOT “BE” What dynaset would result from the criteria “BE” and “BA” in the category field? No records would be selected since you cannot specify 2 mutually exclusive conditions with an And.

List by product the units in stock for both categories BE and BA Products CategoryID ProductName Unitsinstock SupplierID ProductID Price The “OR” operator for a single field’s conditions

The resulting dynaset: The data table: The resulting dynaset:

Products CategoryID ProductName Unitsinstock SupplierID ProductID Price List by product the units in stock for all products but those in category BE You can use the “not” operator for a single field’s conditions

List the products & units in stock for all items with at least 20 units in stock but no more than 30 units in stock Products CategoryID ProductName Unitsinstock SupplierID ProductID Price You can use the “AND” operator for a single field’s conditions

List the products & units in stock for all items with at least 20 units in stock but no more than 30 units in stock Products CategoryID ProductName Unitsinstock SupplierID ProductID Price An alternate syntax: >=20 and <=30 The between syntax allows you to set lower & upper limits - inclusively

For conditions in multiple fields the placement of your arguments determines the Boolean relationship between those arguments: If a criteria is on the same line it is automatically considered an AND If criteria is on a separate line it is automatically considered an OR

List product names for products in category BA with less than 30 units in stock CategoryID ProductName Unitsinstock SupplierID ProductID Price The placement of both criteria on the same line implies an AND relationship

List product names for products in category BA with less than 30 units in stock CategoryID ProductName Unitsinstock SupplierID ProductID Price The placement of both criteria on the same line implies an AND relationship

The resulting dynaset: The data table: The resulting dynaset:

Products CategoryID ProductName Unitsinstock SupplierID ProductID Price List product names for products in category BA with less than 30 units in stock or category BE with more than 31 units in stock Criterion on same line implies AND, Criterion on a separate line implies OR

How does the computer store your query? Access does not store the resulting table from your query - it simply stores the instructions to run the query The actual SQL instructions can be seen in the VIEW menu This is “memory efficient” since it does not require you to save all the information each time you want a different “view” of it. It also insures that each time you use a query “view” you get the most current version.

Summarizing Queries A query is a set of instructions that specifies how to extract and organize data from a database Access provides the QBE grid as a GUI interface to create the SQL code. To properly use the QBE grid you must select the required data (table(s), query), the fields you wish to display and then specify the desired criterion, sorts, groupings and/or expressions.