Microsoft Access 2010 Chapter 7 Using SQL.

Slides:



Advertisements
Similar presentations
Microsoft Access 2010 Chapter 2 Querying a Database.
Advertisements

Concepts of Database Management Seventh Edition
Concepts of Database Management Sixth Edition
Concepts of Database Management Seventh Edition
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
Chapter 5 Creating, Sorting, and Querying a Table
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
Chapter 1 Databases and Database Objects: An Introduction
Access Tutorial 3 Maintaining and Querying a Database
Introduction to Structured Query Language (SQL)
Structured Query Language Part I Chapter Three CIS 218.
Chapter 2 Querying a Database
Concepts of Database Management Sixth Edition
Access Presentation 3 By: Rasagnya Waghray Ali Murtuza.
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
Chapter 2 Querying a Database
Chapter 3 Maintaining a Database
Maintaining and Querying a Database Microsoft Access 2010.
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
Chapter 2 Querying a Database MICROSOFT ACCESS 2010.
Using SQL Queries to Insert, Update, Delete, and View Data Date Retrieval from a single table & Calculations © Abdou Illia MIS Spring 2015.
Chapter 3 Single-Table Queries
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.
Copyright © 2010 Pearson Education, Inc. Publishing as Prentice Hall1 Exploring Microsoft Office Access Committed to Shaping the Next Generation.
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Concepts of Database Management Seventh Edition
Chapter 6 Generating Form Letters, Mailing Labels, and a Directory
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 4 BACKNEXTEND 4-1 LINKS TO OBJECTIVES Query Design Query Criteria Modify a Query Using OR.
Microsoft Access 2010 Building and Using Queries.
Analyzing Data For Effective Decision Making Chapter 3.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
Microsoft Office 2007 Access Chapter 2 Querying a Database.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Concepts of Database Management Seventh Edition
® Microsoft Office 2010 Access Tutorial 3 Maintaining and Querying a Database.
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Microsoft Office 2007 Access Chapter 3 Maintaining a Database.
Querying a Database Access Project 2. 2 What is a Query?  In general, a query is a form of questioning, in a line of inquiry. A query may also refer.
Performing Calculations—1 of 2 In addition to using queries to retrieve, update, sort, and filter data in a database, you can use a query to perform calculations.
® Microsoft Access 2010 Tutorial 3 Maintaining and Querying a Database.
COMPREHENSIVE Access Tutorial 3 Maintaining and Querying a Database.
® Microsoft Office 2013 Access Maintaining and Querying a Database.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
Chapter 6 Creating, Sorting, and Querying a Table
Microsoft Access 2010 Chapter 4 Creating Reports and Forms.
CREATING DATABASE Presenter: Jolanta Soltis. When to use Excel Use Excel when you: –Require a flat or non-relational view of your data (you do not need.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
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.
MSOffice Access Microsoft® Office 2010: Illustrated Introductory 1 Part 2 ® Building Queries.
Creating Advanced Queries and Enhancing Table Design.
1 Chapter 3 Single Table Queries. 2 Simple Queries Query - a question represented in a way that the DBMS can understand Basic format SELECT-FROM Optional.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
Access Maintaining and Querying a Database
Microsoft Office Illustrated Introductory, Windows Vista Edition
Access Tutorial 3 Maintaining and Querying a Database
Access Chapter 2 Querying a Database.
Building and Using Queries
Access Tutorial 5 Creating Advanced Queries and Enhancing Table Design
Chapter 1 Databases and Database Objects: An Introduction
Microsoft Office Illustrated Introductory, Windows XP Edition
Shelly Cashman: Microsoft Access 2016
Assignment 3 Querying and Maintaining a Database
Presentation transcript:

Microsoft Access 2010 Chapter 7 Using SQL

Objectives Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple and compound criteria in SQL queries Use computed fields and built-in functions in SQL queries Sort the results in SQL queries Using SQL

Objectives Use aggregate functions in SQL queries Group the results in SQL queries Join tables in SQL queries Use subqueries Compare SQL queries with Access-generated SQL Use INSERT, UPDATE, and DELETE queries to update a database Using SQL

Project – Using SQL Using SQL

General Project Guidelines Select the fields for the query Determine which table or tables contain these fields Determine criteria Determine sort order Determine grouping Determine any update operations to be performed Using SQL

Changing the Font Size Click File on the Ribbon to open the Backstage view Click Options to display the Access Options dialog box Click Object Designers to display the Object Designer options In the Query design area, click the Size box arrow, and then click the desired font size Click the OK button to close the Access Options dialog box Using SQL

Changing the Font Size Using SQL

Creating a New SQL Query Close the Navigation Pane Display the Create tab Click the Query Design button (Create tab | Queries group) to create a query Close the Show Table dialog box without adding any tables Click the View button arrow (Query Tools Design tab | Results group) to display the View menu Click SQL View to view the query in SQL view Using SQL

Creating a New SQL Query Using SQL

SQL Commands The basic form of SQL expressions is quite simple: SELECT-FROM-WHERE The command begins with a SELECT clause, which consists of the word, SELECT, followed by a list of those fields you want to include Next, the command contains a FROM clause, which consists of the word, FROM, followed by a list of the table or tables involved in the query Finally, there is an optional WHERE clause, which consists of the word, WHERE, followed by any criteria that the data you want to retrieve must satisfy Using SQL

SQL Commands Using SQL

Preparing to Enter a New SQL Query Click the View button arrow (Home tab | Views group) to display the View button menu Click SQL View to return to SQL view Using SQL

Including All Fields To include all fields, you could use the same approach as in the previous steps, that is, list each field in the table after the word, SELECT There is a shortcut, however. Instead of listing all the field names after SELECT, you can use the asterisk (*) symbol Using SQL

Including All Fields Using SQL

Using a Criterion Involving a Numeric Field To restrict the records to be displayed, include the word WHERE followed by a criterion as part of the command If the field involved is a numeric field, you simply type the value Using SQL

Simple Criteria A simple criterion has the form: field name, comparison operator, then either another field name or a value Using SQL

Using a Comparison Operator Using SQL

Using a Criterion Involving a Text Field If the criterion involves a text field, the value must be enclosed in single quotation marks Using SQL

Using a Wildcard In most cases, the conditions in WHERE clauses involve exact matches The LIKE operator uses one or more wildcard characters to test for a pattern match One common wildcard in Access, the asterisk (*), represents any collection of characters Using SQL

Using a Wildcard Using SQL

Compound Criteria Compound criteria are formed by connecting two or more simple criteria using AND, OR, and NOT When simple criteria are connected by the word AND, all the simple criteria must be true in order for the compound criterion to be true When simple criteria are connected by the word OR, the compound criterion will be true whenever any of the simple criteria are true Preceding a criterion by the word NOT reverses the truth or falsity of the original criterion Using SQL

Using a Compound Criterion Involving AND Using SQL

Using a Compound Criterion Involving OR Using SQL

Using NOT in a Criterion Using SQL

Using a Computed Field Just as with queries created in Design view, you can include fields in queries that are not in the database, but that can be computed from fields that are in the database Called a computed field Can involve addition, subtraction, multiplication, or division To indicate the contents of the new field (the computed field), you can name the field by following the computation with the word, AS, and then the name you want to assign the field Using SQL

Using a Computed Field Using SQL

Sorting To sort the output, you include an ORDER BY clause, which consists of the words ORDER BY followed by the sort key Using SQL

Sorting the Results on a Single Field Using SQL

Sorting the Results on Multiple Fields Using SQL

Sorting the Results in Descending Order To sort in descending order, you follow the name of the sort key with the DESC operator Using SQL

Omitting Duplicates When Sorting The DISTINCT operator eliminates duplicate values in the results of a query To use the operator, you follow the word DISTINCT with the field name in parentheses Using SQL

Using a Built-In Function SQL has built-in functions, also called aggregate functions, to perform various calculations COUNT SUM AVG MAX MIN Using SQL

Using a Built-In Function Using SQL

Assigning a Name to the Results of a Function You can assign a name to the results of a function To do so, follow the expression for the function with the word AS and then the name to be assigned to the result Using SQL

Using Multiple Functions in the Same Command Using SQL

Using Grouping Grouping means creating groups of records that share some common characteristic When you group rows, any calculations indicated in the SELECT command are performed for the entire group GROUP BY clause Using SQL

Using Grouping Using SQL

Restricting the Groups that Appear The HAVING clause, which consists of the word HAVING followed by a criterion, is used to restrict the groups to be included Using SQL

Joining Tables Many queries require data from more than one table Using SQL

Restricting the Records in a Join You can restrict the records to be included in a join by creating a compound criterion Using SQL

Aliases When tables appear in the FROM clause, you can give each table an alias, or an alternative name, that you can use in the rest of the statement Using SQL

Aliases Using SQL

Joining a Table to Itself Using SQL

Joining a Table to Itself Using SQL

Subqueries A subquery is a query within another query Using SQL

Using an INSERT Command You can add records to a table using the SQL INSERT command The command consists of the words INSERT INTO followed by the name of the table into which the record is to be inserted Next is the word VALUE followed by the values for the fields in the record Values for Text fields must be enclosed within quotation marks Using SQL

Using an INSERT Command Using SQL

Using an UPDATE Command You can update records in SQL by using the UPDATE command The command consists of UPDATE, followed by the name of the table in which records are to be updated Next, the command contains one or more SET clauses, which consist of the word SET, followed by a field to be updated, an equal sign, and the new value Using SQL

Using an UPDATE Command Using SQL

Using a DELETE Command You can delete records in SQL using the DELETE command The command consists of DELETE FROM, followed by the name of the table from which records are to be deleted Finally, you include a WHERE clause to specify the criteria Using SQL

Using a DELETE Command Using SQL

Chapter Summary Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple and compound criteria in SQL queries Use computed fields and built-in functions in SQL queries Sort the results in SQL queries Using SQL

Chapter Summary Use aggregate functions in SQL queries Group the results in SQL queries Join tables in SQL queries Use subqueries Compare SQL queries with Access-generated SQL Use INSERT, UPDATE, and DELETE queries to update a database Using SQL

Microsoft Access 2010 Chapter 7 Complete