CS&E 1111 AcQueries Writing Simple Queries in Access Displaying on specific data fields Filtering data using criteria Objectives: Learn how to use the.

Slides:



Advertisements
Similar presentations
Database Management Systems and Enterprise Software
Advertisements

Chapter 6 UNDERSTANDING AND DESIGNING QUERIES AND REPORTS.
Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
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.
Computer Science & Engineering 2111 CSE 2111 Lecture Querying a Database 1CSE 2111 Lecture- Querying a Database.
Microsoft Access 2010 Chapter 7 Using SQL.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 3 – Finding, Filtering,
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Create Forms Lesson 5. Software Orientation Creating Forms A form is a database object –enter, edit, or display data from a table or query Providing.
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
1 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Introduction to Access By Mary Ann Chaney and Alicia Harkleroad.
1 Chapter 1: Finding Your Way Through a Database Exploring Microsoft Office Access 2010.
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.
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.
Microsoft Access 2003 Define some key Access terminology: Field – A single characteristic or attribute of a person, place, object, event, or idea. Record.
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.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. ACCESS 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 6 – Designing.
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.
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.
SESSION 3.1 This section covers using the query window in design view to create a query and sorting & filtering data while in a datasheet view. Microsoft.
Computer Science & Engineering 2111 Querying a Database 1CSE 2111 Lecture- Querying a Database.
Microsoft Office Illustrated Introductory, Premium Edition Using Tables and Queries.
1 Chapter 1: Finding Your Way Through a Database Exploring Microsoft Office Access 2007.
Computer Science & Engineering 2111 CSE 2111 Lecture Multiple and Compound Criteria in Queries 1 CSE 2111 Lecture-Multiple and Compound Criteria in Queries.
® Microsoft Office 2013 Access Creating a Database.
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.
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
1 Chapter 3: Customize, Analyze, and Summarize Query Data Exploring Microsoft Office Access 2007.
Access Chapter 3-Obtaining Answers to Your Data Questions.
IS201 Agenda: 09/19  Modify contents of the database.  Discuss queries: Turning data stored in a database into information for decision making.  Create.
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.
Access Queries Agenda 6/16/14 Review Access Project Part 1, answer questions Discuss queries: Turning data stored in a database into information for decision.
Queries Objective 5.02 Understand queries, forms, and reports used in business.
Microsoft Access Database Creation and Management.
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.
ACCESS LESSON 1 DATABASE BASICS VOCABULARY. BACKSTAGE VIEW A menu of options and commands that allows you to access various screens to perform common.
Computer Science & Engineering 2111 Inner Joins and Advanced Queries 1CSE 2111 Lecture-Advanced Queries.
Writing Simple Queries in Access
Querying in Access Objectives: Learn how to use the Access Query Design Tool manipulate data in Access: Sorting data Aggregating Data Performing Calculations.
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.
Microsoft Office Illustrated Fundamentals
Access Maintaining and Querying a Database
Microsoft Office Access 2003
Database Queries.
Microsoft Office Access 2003
Presentation transcript:

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

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

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

CS&E 1111 AcQueries Writing a Criterion Criteria is a collection of criterion or conditions: l 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

CS&E 1111 AcQueries Foreign Key Primary Key Products: Suppliers: Consider the following database :

CS&E 1111 AcQueries Create a list of products by name and the number of units in stock for each No conditions Products CategoryID ProductName Unitsinstock SupplierID ProductID Price

CS&E 1111 AcQueries 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?

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

CS&E 1111 AcQueries The data table: The resulting dynaset:

CS&E 1111 AcQueries Relational operators in a query: =, =, <>, l With Numbers <= 10 values of less than or equal to 10 l 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.

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

CS&E 1111 AcQueries The data table: The resulting dynaset:

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

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

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

CS&E 1111 AcQueries 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.

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

CS&E 1111 AcQueries The data table: The resulting dynaset:

CS&E 1111 AcQueries 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 Products CategoryID ProductName Unitsinstock SupplierID ProductID Price

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

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

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

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

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

CS&E 1111 AcQueries The data table: The resulting dynaset:

CS&E 1111 AcQueries 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 Products CategoryID ProductName Unitsinstock SupplierID ProductID Price Criterion on same line implies AND, Criterion on a separate line implies OR

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

CS&E 1111 AcQueries Summarizing Queries l A query is a set of instructions that specifies how to extract and organize data from a database l Access provides the QBE grid as a GUI interface to create the SQL code. l 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.