Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.

Slides:



Advertisements
Similar presentations
Access Manual 4 By Elham S.Khorasani Ismail Guneydas Dhawala Kovuri.
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
Benchmark Series Microsoft Access 2010 Level 1
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Microsoft Office 2010 Access Chapter 1 Creating and Using a Database.
Access Lesson 2 Creating a Database
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
Access Tutorial 3 Maintaining and Querying a Database
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 3 1 Microsoft Office Access 2003 Tutorial 3 – Querying a Database.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
FIS 318/618: Financial Systems & Databases Queries Oakland University School of Business Administration Accounting and Finance Joe Callaghan.
Creating And Maintaining A Database. 2 Learn the guidelines for designing databases When designing a database, first try to think of all the fields of.
Querying a Database Microsoft Office Access 2003.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 3 Maintaining a Database Using the Design and Update Features of Access.
Chapter Extension 6 Using Microsoft Access © 2008 Pearson Prentice Hall, Experiencing MIS, David Kroenke.
Getting Started with Microsoft Access The Access Workbench: Section One DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
Access Tutorial 10 Automating Tasks with Macros
Chapter 9 Macros, Navigation Forms, PivotTables, and PivotCharts
Chapter 2 Querying a Database
Chapter 3 Maintaining a Database
Maintaining and Querying a Database Microsoft Access 2010.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 13 Managing Databases with SQL Server 2000.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1. Chapter 2: Relational Databases and Multi-Table Queries Exploring Microsoft Office.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access 2007 Committed to Shaping the Next Generation of.
With Microsoft Office 2007 Intermediate© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Intermediate.
With Microsoft Access 2007 Volume 1© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Access 2007 Volume 1 Chapter.
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Copyright © 2008 Pearson Prentice Hall. All rights reserved.1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational Databases.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall 1 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2: Relational.
You can use a query to view a subset of your data or to answer questions about your data. For example, if you want to view a list of student names and.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Chapter 6 Advanced Report Techniques
CSS/417 Introduction to Database Management Systems Workshop 2.
McGraw-Hill/Irwin ©2009 The McGraw-Hill Companies, All Rights Reserved Business Driven Information Systems 2e Plug-In T6: Basic Skills and Tools Using.
Lesson 2.  To help ensure accurate data, rules that check entries against specified values can be applied to a field. A validation rule is applied to.
Working with Multiple Tables in Microsoft Access The Access Workbench: Section Two DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
XP New Perspectives on Microsoft Access 2002 Tutorial 21 Microsoft Access Tutorial 2 – Creating And Maintaining A Database.
XP 1 Microsoft Access 2003 Introduction To Microsoft Access 2003.
XP New Perspectives on Microsoft Office Access 2003, Second Edition- Tutorial 2 1 Microsoft Office Access 2003 Tutorial 2 – Creating And Maintaining A.
MS-ACCESS BY SANGEETHA PARTHASARATHY Topics to be covered §Comparing Values in Selection Criteria §Calculating Values in a Query §Changing the appearance.
McGraw-Hill/Irwin © 2008 The McGraw-Hill Companies, All Rights Reserved Plug-In T6: Basic Skills and Tools Using Access 2010 Business Driven Technology.
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
Part II. Query Types On the design query table pane, right click and the cascading window will appear.
Office 2003 Post-Advanced Concepts and Techniques M i c r o s o f t Access Project 7 Advanced Report and Form Techniques.
© 2002 by Prentice Hall 1 Database Processing with Microsoft Access David M. Kroenke Database Concepts 1e Appendix A.
® Microsoft Office 2013 Access Creating a Database.
BUSINESS DRIVEN TECHNOLOGY Plug-In T5 Touring Access.
Tutorial 9 Using Action Queries and Advanced Table Relationships.
Relationships in Microsoft Access The Access Workbench: Section Five DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
McGraw-Hill/Irwin © The McGraw-Hill Companies, All Rights Reserved TECHNOLOGY PLUG-IN T6 Basic Skills Using Access.
A Skills Approach Access 2010 Working with Tables © 2012 The McGraw-Hill Companies, Inc. All rights reserved Chapter 2.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
Course ILT Forms and queries Unit objectives Create forms by using AutoForm and the Form Wizard, and add or modify form headers and footers Open and enter.
Database Processing with Microsoft Access Appendix DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
You can sort Access data so you can view records in the order you want to view them, and you can filter data so you only see the records you want to see.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 7 1 Microsoft Office FrontPage 2003 Tutorial 8 – Integrating a Database with a FrontPage.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
Work with Tables and Database Records Lesson 3. NAVIGATING AMONG RECORDS Access users who prefer using the keyboard to navigate records can press keys.
Modify Tables and FieldsModify Tables and Fields Lesson 4 © 2014, John Wiley & Sons, Inc.Microsoft Official Academic Course, Microsoft Word Microsoft.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 1 ® Database & Table.
Office 2003 Introductory Concepts and Techniques M i c r o s o f t Access Project 2 Querying a Database Using the Select Query Window.
SQL server Section 2&3. What are Data Types Character Data Types Number Data Types Date and Time Data Types CAST and CONVERT functions TRY_PARSE and TRY_CONVERT.
Access Queries and Forms. Adding a New Field  To insert a field after you have saved your table, open Access, and open the table  It is easier to add.
Copyright © 2014 Pearson Canada Inc. Ext. 5b-1 Copyright © 2014 Pearson Canada Inc. Application Extension 5b Using Microsoft Access Part 2: Using Information.
SQL MODELER - OPEN There are Three Ways to open the SQL Modeler
Tutorial 3 – Querying a Database
Presentation transcript:

Working with Queries in Microsoft Access The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-2 Section Objectives  Learn how to use Microsoft Access to:  Run Access SQL statements  Run queries in single and multiple tables in using both SQL and Query By Example (QBE)  Manually set table and relationship properties not supported by Access SQL

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-3 Using Access QBE: The SQL Query to be Run SELECT* FROM CUSTOMER;

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-4 Using Access SQL: The Queries Pane Double-click Create query in Design view to create a new query The Queries Pane Click Queries to display the Queries Pane

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-5 Using Access SQL: The Show Table Dialog Box Show Table Dialog Box Query1: Select Query window

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-6 Using Access SQL: The Query1: Select Query Window in Design View SQL View button Query1: Select Query window in Design View

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-7 Using Access SQL: The Query1: Select Query Window in SQL View Query1: Select Query window in SQL View Design View button

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-8 Using Access SQL: The SQL Query The SQL query text The Execute Query button The Save Query button

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-9 Using Access SQL: The Query Results

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-10 Using Access SQL: The Save As Dialog Box The Save Query button The Save As dialog box Type new query name here

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-11 Using Access SQL: The SQLQuery-AW-3-01: Select Query Window The query has been renamed as SQLQuery-AW-3-01

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-12 Using Access SQL: The SQLQuery-AW-3-01 Object in the Queries Pane The SQLQuery-AW-3-01 query object

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-13 Using Access QBE: The SQL Query to be Run SELECT* FROM CUSTOMER;

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-14 Using Access QBE: The Show Table Dialog Box Show Table Dialog Box Query1: Select Query window

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-15 Using Access QBE: The QBE Query1 : Select Query Window Tables in the query appear in the top pane, together with a list of their columns (the “field list”) and an asterisk (*) meaning “all columns” Columns in the query are called fields and appear in the bottom pane, together with related property values

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-16 Using Access QBE: Adding Columns to the Query To add a column to the query, click the column name and drag it to a cell in the Field: row in the lower window pane The asterisk (*) symbol was dragged and dropped here to add the CUSTOMER.* field to the query The table name is automatically added to the query to specify the source of the column–this is important if there is more than one table in the query with the same column name

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-17 Using Access QBE: The Query Results The results are sorted by CustomerID As expected, the query results are identical to those shown in the SQL query

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-18 Using Access QBE: The SQL Query to be Run SELECT CustomerID, LastName, FirstName FROM CUSTOMER;

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-19 Using Access QBE: Selecting Individual Fields The CustomerID, LastName, and FirstName fields are in the query The results will be sorted by LastName in descending order (Z–A) The results will show only customers with a CustomerID greater than 2

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-20 Using Access QBE: The SQL Query to be Run SELECT LastName, FirstName, Date, Type, Remarks FROM CUSTOMER, CONTACT WHERE CUSTOMER.CustomerID = CONTACT.CustomerID AND CustomerID = 3 ORDER BY Date;

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-21 Using Access QBE: The Query Window with the Two Tables Both the CONTACT table and CUSTOMER table are in the query The relationship and referential integrity constrain between the two tables is automatically included in the query—this means that the SQL clause WHERE CUSTOMER.CustomerID = CONTACT.CustomerID is automatically part of the query

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-22 Using Access QBE: The Complete Two Table Query From CUSTOMER, the CustomerID, LastName, and FirstName columns are in the query From CONTACT, the Date, Type, and Remarks columns are in the query The results will be sorted by Date in ascending order (A–Z) The results will be shown only for the customer with a CustomerID of 3

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-23 Using Access QBE: The Two Table Query Results The results are shown for the customer with the CustomerID of 3, which is Jessica Christman The results are sorted by Date in ascending order (earliest date to latest date)

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-24 Using Access QBE: The SQL Query to be Run SELECT LastName, FirstName, Date, Type, Remarks FROM CUSTOMER, CONTACT WHERE CUSTOMER.CustomerID = CONTACT.CustomerID AND CustomerID = [?] ORDER BY Date; The query now contains an unknown value for CustomerID—we will use a query with a prompt that will be displayed to allow the user to enter a parameter value when the query is run

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-25 Using Access QBE: Using a Parameterized Query The Criteria for the CustomerID column now contains the text for a prompt to be displayed in the Enter Parameter Value dialog box that will be displayed to get a parameter value from the user The CustomerID column is now shown last because it is not displayed in the query results

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-26 Using Access QBE: The Enter Parameter Value Dialog Box Enter the CustomerID number here Click the OK button to run the query This is the text that was entered into the criteria field for CustomerID

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-27 Using Access QBE: The Two Table Query Results The user input the parameter value of 3, so the results are shown for the customer with the CustomerID of 3, which is Jessica Christman

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-28 SALESPERSON Table Column Characteristics Column NameTypeKeyRequiredRemarks NickNameText (35)Primary KeyYes LastNameText (25)NoYes FirstNameText (25)NoYes HireDateDate/TimeNoYes WageRateNumberNoYesDouble, Default value = $12.50 CommissionRateNumberNoYesDouble PhoneText (12)NoYes Text (100)NoYesUnique SALESPERSON

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-29 SALESPERSON Data NickNameLastNameFirstNameHireDateWageRate Commission Rate TinaSmithTina10-AUG % Big BillJonesWilliam25-SEP % BillyJonesBill17-MAY % NickNamePhone Big

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-30 SQL to Create the SALESPERSON Table CREATE TABLE SALESPERSON( NickNameChar(35)NOT NULL, LastNameChar(25)NOT NULL, FirstNameChar(25)NOT NULL, HireDateDateTimeNOT NULL, WageRateNumeric(5,2)NOT NULL DEFAULT(12.50), CommissionRateNumeric(5,3)NOT NULL, PhoneChar(12)NOT NULL, Varchar(100)NOT NULL UNIQUE, CONSTRAINTSALESPERSON_PK PRIMARY KEY(NickName) );

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-31 SQL to Create the SALESPERSON Table Modified for ACCESS ANSI-89 SQL CREATE TABLE SALESPERSON( NickNameChar(35)NOT NULL, LastNameChar(25)NOT NULL, FirstNameChar(25)NOT NULL, HireDateDateTimeNOT NULL, WageRateNumericNOT NULL, CommissionRateNumericNOT NULL, PhoneChar(12)NOT NULL, Varchar(100)NOT NULL, CONSTRAINTSALESPERSON_PK PRIMARY KEY(NickName) );

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-32 The CREATE TABLE SALESPERSON SQL Statement

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-33 The Create-Table SALESPERSON Query in the Queries Pane The Create-Table-SALESPERSON query–note the Design icon that identifies this as a data definition query Click the Tables button to move to the Tables pane

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-34 The SALESPERSON Table in the Tables Pane The SALESPERSON table object–click the object to select it After selecting a table, click the Design View button to open the table in Design View

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-35 The SALESPERSON Table in Design View Move the mouse cursor here, then click to select the WageRate column (field) The General tab in the Field Properties section

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-36 The WageRate Field Properties The Decimal Places text box The Default Value text box The WageRate column is selected The Format text box

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-37 The Format Text Box Click in the Format text box to select it Click the Format text box drop-down arrow to display the drop-down list Select Currency

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-38 The Default Value Text Box The Property Update Options icon— you can simply ignore it The Expression Builder icon—we will not use it in this situation Click in the Default Value text box to select it

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-39 The Completed WageRate Field Properties Click the Save button to save the change to the SALESPERSON table design Data format is set to Currency Number of decimal places is set to 2 The default value is set to 12.50

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-40 The Field Properties The column is selected The Indexed text box Select Yes (No Duplicates)

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-41 Specifying a Validation Rule Enter the possible values for the column in the Validation Rule text box

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-42 SQL to Insert Data into the SALESPERSON Table INSERT INTO SALESPERSON VALUES('Tina', 'Smith', 'Tina', '10-AUG-04', 15.50,.125, ' ', INSERT INTO SALESPERSON VALUES('Big Bill', 'Jones', 'William', '25-SEP-04', 15.50,.125, ' ', INSERT INTO SALESPERSON VALUES('Billy', 'Jones', 'Bill', '17-MAY-05', 12.50,.120, ' ',

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-43 Inserting Data Into The SALESPERSON Table The INSERT command The dialog box confirming the INSERT Click the Yes button to complete the INSERT

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-44 The Data in the SALESPERSON Table The data is sorted by NickName (the primary key value) in ascending order

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-45 CUSTOMER.NickName Column Characteristics Column NameTypeKeyRequiredRemarks NickNameText (35)Foreign KeyYes CUSTOMER

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-46 CUSTOMER.NickName Data CustomerIDLastNameFirstName...NickName 1GriffeyBen...Big Bill 3ChristmanJessica...Billy 4ChristmanRob...Tina 5HayesJudy...Tina

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-47 SQL to Alter the CUSTOMER Table ALTER TABLE CUSTOMER ADD NickName Char(35) NULL; UPDATE CUSTOMER SETNickName = 'Big Bill' WHERECustomerID = 1; UPDATE CUSTOMER SETNickName = 'Billy' WHERECustomerID = 3; UPDATE CUSTOMER SETNickName = 'Tina' WHERECustomerID = 4; UPDATE CUSTOMER SETNickName = 'Tina' WHERECustomerID = 5; ALTER TABLE CUSTOMER ALTER COLUMN NickName Char(35) NOT NULL;

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-48 The Altered CUSTOMER Table The added NickName column The column is required, which is the Access equivalent of NOT NULL

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-49 The Relationships Window with the Current Relationship Diagram This is the relationship diagram as we created it in Section 2’s “The Access Workbench” The Show Table button

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-50 The Updated Relationship Diagram The relationship between SALESPERSON and CUSTOMER already exists—it was created using SQL—so right-click the relationship line and then click Edit Relationship in the shortcut menu that appears to display the Edit Relationships dialog box

KROENKE and AUER - DATABASE CONCEPTS (3 rd Edition) © 2008 Pearson Prentice Hall AW-3-51 The Completed Edit Relationships Dialog Box The Enforce Referential Integrity check box is already selected because of the SQL CONSTRAINT FOREIGN KEY statement Check the Cascade Update Related Fields check box to set the equivalent of the SQL ON UPDATE CASCADE statement Leave the Cascade Delete Related Fields check box unchecked—this is equivalent to the SQL ON DELETE NO ACTION statement

Working with Queries in Microsoft Access End of Presentation on The Access Workbench: Section Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 3 rd Edition