Queries and SQL in Access Please use speaker notes for additional information!

Slides:



Advertisements
Similar presentations
Structured Query Language (SQL)
Advertisements

Database Queries and Structured Query Language (SQL) J.G. Zheng May 16 th 2008.
Databases Section 4: Select Queries Presented By: Lindani Ncube Based on Materials by: M Halse.
Microsoft Access 2010 Chapter 7 Using SQL.
CORE 2: Information systems and Databases STORAGE & RETRIEVAL 2 : SEARCHING, SELECTING & SORTING.
Sorting data and Other selection Techniques Ordering data results Allows us to view our data in a more meaningful way. Rather than just a list of raw.
INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 16 – SQL SEAN J. TAYLOR.
1 Section 5 - Grouping Data u The GROUP BY clause allows the grouping of data u Aggregate functions are most often used with the GROUP BY clause u GROUP.
SESSION 5.1 In this session we will be exploring Pattern Match Queries List-Of-Values Queries, Non-Matching Values in Queries Both the “And” and the “OR”
Chapter 2 Basic SQL SELECT Statements Oracle 10g: SQL.
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.
SQL/lesson 2/Slide 1 of 45 Retrieving Result Sets Objectives In this lesson, you will learn to: * Use wildcards * Use the IS NULL and IS NOT NULL keywords.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
SQL Chapter Two. Overview Basic Structure Verifying Statements Specifying Columns Specifying Rows.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
SQL and Conditions Speaker notes will provide additional information!
Database Applications – Microsoft Access Lesson 4 Working with Queries 36 Slides in Presentation.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
I want to do SQL, I start as if I am doing a regular query.
When I want to work with SQL, I start off as if I am doing a regular query.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
Information Resource Engineering SQL3. Recap- SQL Rules and Conventions  Certain ‘keywords’ are ‘reserved’ and have special meaning in SQL e.g.: SELECT,
Introduction to Oracle - SQL Additional information is available in speaker notes!
Databases.  A database is simply a collection of information stored in an orderly manner.  A database can be as simple as a birthday book, address book.
XP New Perspectives on Microsoft Access 2002 Tutorial 31 Microsoft Access 2002 Tutorial 3 – Querying a Database.
ORDER BY clause in SELECT command: Normally, the result of the query will not be in ordered format. If we want to get the result of the query in specific.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
LINQ to DATABASE-2.  Creating the BooksDataContext  The code combines data from the three tables in the Books database and displays the relationships.
A am going to create a table in design view. I am going to create a table in an Access database that contains information about the books that I have on.
Sorting data and Other selection Techniques Ordering data results Allows us to view our data in a more meaningful way. Rather than just a list of raw.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
Finish ing the logic flowc harts from week 3.. if invcd = “A” and (amtfst > 500 or amtsnd > 200) move “OKAY” to msg end if With the parenthesis, invcd.
More about maintaining a table Use speaker notes for additional information!
Creating a database - I clicked on blank database and am saving it as books10.mdb. For more information see the practice example under week #1. I am going.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Writing Basic SQL SELECT Statements Lecture
Data Please use speaker notes for additional information!
1 Structured Query Language (SQL) Pertemuan 09 Matakuliah: F0712 / Lab MS Access Tahun: 2007.
1 Section 3 - Select Statement u The Select statement allows you to... –Display Data –Specify Selection Criteria –Sort Data –Group Data for reporting –Use.
IF Statements flowcharts and pseudocode Please open the speaker notes - they contain additional information!
IFS180 Intro. to Data Management Chapter 10 - Unions.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
The data in the table.. Starting a query. Two criteria in an AND relationship.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
Writing Basic SQL SELECT Statements
 2012 Pearson Education, Inc. All rights reserved.
Single Table Queries in SQL
Dumps4Download Oracle 1z0-051 Exam Dumps - Oracle 1z0-051 Exam Dumps Questions
PROC SQL, Overview.
Access Database for CIS17
Please use speaker notes for additional information!
Using the Set Operators
Database Queries.
Access and Condition Statements
Generating forms with the wizard in Access
Tutorial 3 – Querying a Database
LINQ to DATABASE-2.
Access Database for CIT12
Writing Basic SQL SELECT Statements
Please use speaker notes for additional information!
Introduction to Access
Section 4 - Sorting/Functions
Notes on SQL This slide show will introduce SQL using Access. It assumes only an introductory level of knowledge about Access.
Queries and SQL in Access
Using SQL with Access I create a database named
either of two other things (an OR relationship between them)
Presentation transcript:

Queries and SQL in Access Please use speaker notes for additional information!

Textbook.mdb

Query - all fields, all rows

Query with SQL All columns/fields for all rows/records means that in this case all of the columns/fields are listed in the SELECT clause with their table name in front. The table name also appears in the FROM clause Note that SQL code end with a semi-colon.

SQL versions In this version, the book.ISBN has been changed to ISBN - this has been applied to all columns/fields. The table name is only needed if two tables are being used and the column/field appears on both. In this version, the SELECT * means select all columns/fields. You only need to list the columns/fields by name if you want only specific ones to appear in the results.

Query - AND This is an AND query asking for all books with a year published greater than 1998 AND a price > 40. The results are shown below.

SQL for AND query The SELECT statement is specifying certain fields/columns that should be shown. In this case the fields are ISBN, title, yrpub and price. As you can see the table name is shown in front of the column name in the format book.ISBN etc. The FROM clause specifies the table name. The WHERE clause gives the condition. In this case the condition is the yrpub > 1998 or price > 40.

SQL - AND The SELECT only lists the columns/fields by name because there is no chance of duplication with only one table being used. The WHERE is coded by simply using the column name, the comparison operator and the field being compared against is in quotes because it was defined as a text field. 40 is not in quotes because it was defined as a number (currency) field.

OR Query Yrpub must be greater than 1999 OR price must be greater than 40. Either one is sufficient.

SQL - OR Again I have eliminated the table name in the select because there is no chance for duplication and the multiple parenthesis in the WHERE.

AND - OR The table is shown in ascending order by ISBN. The query wants books with price greater than 40 AND with a pubid of either 001 OR 002.

AND - OR Notice the ORDER BY ISBN clause which accomplishes the ascending sort. Logic: cond A AND either (cond B OR cond C) Note the way the OR is expressed.