© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language.

Slides:



Advertisements
Similar presentations
Structured Query Language b Querying a Single Table b Querying Multiple Tables b EXISTS and NOT EXISTS b Changing Data.
Advertisements

Introduction to Structured Query Language (SQL)
The University of Akron Dept of Business Technology Computer Information Systems The Relational Model: Query-By-Example (QBE) 2440: 180 Database Concepts.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 4-1 David M. Kroenke Database Processing Chapter 2 Structured Query Language.
© 2002 by Prentice Hall 1 SI 654 Database Application Design Winter 2004 Dragomir R. Radev.
Fundamentals, Design, and Implementation, 9/e COS 346 Day 11.
SQL Basics Based on the relational algebra we just learned. Nonprocedural language – what to be done not how Simple, powerful language Used for both data.
Fundamentals, Design, and Implementation, 9/e Chapter 6 Introduction to Structured Query Language (SQL)
Structured Query Language Part I Chapter Three CIS 218.
Structured Query Language Chapter Three (Excerpts) DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 6 th Edition.
Structured Query Language Chapter Three DAVID M. KROENKE’S DATABASE CONCEPTS, 2 nd Edition.
Concepts of Database Management Sixth Edition
A Guide to SQL, Seventh Edition. Objectives Retrieve data from a database using SQL commands Use compound conditions Use computed columns Use the SQL.
Microsoft Access 2010 Chapter 7 Using SQL.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
Structured Query Language
©Silberschatz, Korth and Sudarshan4.1Database System Concepts Chapter 4: SQL Basic Structure Set Operations Aggregate Functions Null Values Nested Subqueries.
Using SQL Queries to Insert, Update, Delete, and View Data Date Retrieval from a single table & Calculations © Abdou Illia MIS Spring 2015.
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 5 th Edition.
Chapter 3 Single-Table Queries
Structured Query Language Chapter Three DAVID M. KROENKE and DAVID J. AUER DATABASE CONCEPTS, 4 th Edition.
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.
Fundamentals, Design, and Implementation, 9/e CPE 481 Database Processing Chapter 6 Structured Query Language (SQL) Instructor:Suthep Madarasmi, Ph.D.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
Using Special Operators (LIKE and IN)
Concepts of Database Management Seventh Edition
Database Processing: Fundamentals, Design, and Implementation, 9/e by David M. KroenkeChapter 6/1 Copyright © 2004 Please……. No Food Or Drink in the class.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
SQL for Data Retrieval. Running Example IST2102 Data Preparation Login to SQL server using your account Select your database – Your database name is.
Chapter 9 Structured Query Language David M. Kroenke Database Processing © 2000 Prentice Hall.
BACS 287 Structured Query Language 1. BACS 287 Visual Basic Table Access Visual Basic provides 2 mechanisms to access data in tables: – Record-at-a-time.
Concepts of Database Management Eighth Edition Chapter 3 The Relational Model 2: SQL.
STRUCTURED QUERY LANGUAGE SQL-II IST 210 Organization of Data IST210 1.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
Database Management COP4540, SCS, FIU Structured Query Language (Chapter 8)
SQL “Structured Query Language; standard language for relational data manipulation” DB2, SQL/DS, Oracle, INGRES, SYBASE, SQL Server, dBase/Win, Paradox,
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
(C) 2000, The University of Michigan 1 Database Application Design Handout #5 February 4, 2000.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
1/18/00CSE 711 data mining1 What is SQL? Query language for structural databases (esp. RDB) Structured Query Language Originated from Sequel 2 by Chamberlin.
Structured Query Language
© 2002 by Prentice Hall 1 Structured Query Language David M. Kroenke Database Concepts 1e Chapter 3 3.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
+ Structured Query Language Part 2 KROENKE and AUER - DATABASE CONCEPTS (6th Edition) Copyright © 2013 Pearson Education, Inc. Publishing as Prentice Hall.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
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.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
Lecture3b - Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data Guide to Oracle 10g ITBIS373 Database Development.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
Structured Query Language SQL-II IST 210 Organization of Data IST2101.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
SQL Query Getting to the data ……..
Structured Query Language
Structured Query Language
CH 9 SQL 9.1 Querying A Single Table 9.2 Querying Multiple Tables
PL/SQL LANGUAGE MULITPLE CHOICE QUESTION SET-1
SQL FUNDAMENTALS CDSE Days 2018.
Chapter 4 Summary Query.
Access: SQL Participation Project
Structured Query Language
CS4222 Principles of Database System
Shelly Cashman: Microsoft Access 2016
Presentation transcript:

© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language

© 2002 by Prentice Hall 2 Structure Query Language Structure Query Language is known as either –Its acronym, SQL, or –SEQUEL, the name of the original version of SQL SEQUEL was developed by IBM in the mid-1970s.

© 2002 by Prentice Hall 3 SQL, not a Procedural Programming Language SQL is not a programming language itself, it is a data access language SQL may be embedded in traditional procedural programming languages (like COBOL)

© 2002 by Prentice Hall 4 SQL Syntax SQL is not case sensitive. SELECT field(s) ‘what columns will be retrieved FROM table(s); ‘which table contains the column data e.g., SELECT Name, Phone FROM Student;

© 2002 by Prentice Hall 5 The DISTINCT Qualifier Eliminating duplicate rows on the output… SELECT DISTINCT StateAddress FROM Employee;

© 2002 by Prentice Hall 6 The WHERE Clause Reducing the output based on specified criteria… SELECT StudentName FROM Students WHERE GradePointAverage >= 3.0;

© 2002 by Prentice Hall 7 Comparison Operators Equals = Not equals <> Greater than > Less than < Greater than or equal to >= Less than or equal to <= Within a list of values IN A logical NOT Within a range BETWEEN

© 2002 by Prentice Hall 8 IN a List of Values SELECT StudentName FROM Student WHERE State IN [‘PA’, ‘MA’, ‘CA’];

© 2002 by Prentice Hall 9 The Logical NOT SELECT StudentName FROM Students WHERE State NOT IN [‘NJ’, ‘NM’, ‘NY’]; SELECT StudentName FROM Students WHERE NOT GradePointAverage >= 3.0;

© 2002 by Prentice Hall 10 Within a Range of Values SELECT StudentName FROM Student WHERE StudentID BETWEEN 250 and 300;

© 2002 by Prentice Hall 11 Using Wildcard Character Substitutions The LIKE keyword is used in place of the = sign when you use wildcard characters. The underscore character (_) is a single character substitution The percent character (%) is a multi- character substitution

© 2002 by Prentice Hall 12 Using LIKE SELECT StudentID FROM Student WHERE StudentName LIKE ‘K%’; SELECT PartName FROM Part WHERE PartNumber LIKE ‘_ABC%’;

© 2002 by Prentice Hall 13 NULL Means Nothing A NULL character means that nothing has been entered. This is different from a space or a zero. SELECT Name FROM Student WHERE Major IS NULL;

© 2002 by Prentice Hall 14 ORDER BY… Sorting Outputs Sorting in descending order… SELECT StudentID, Name FROM Student ORDER BY Name DESC; Sorting in ascending order… SELECT StudentID, Name FROM Student ORDER BY Name ASC;

© 2002 by Prentice Hall 15 Built-in Functions Counting number of rows COUNT Adding the values in a column SUM Averaging the values in a column AVG Finding the maximum value in a column MAX Finding the minimum value in a column MIN

© 2002 by Prentice Hall 16 Built-in Functions SELECT Count (*) FROM Student WHERE State = ‘WI’; SELECT Sum (Amount) FROM SalesReceipt; SELECT Max (Score) FROM Assignments;

© 2002 by Prentice Hall 17 Grouping the Output SELECT Name, State FROM Student GROUP BY State;

© 2002 by Prentice Hall 18 Reducing the Groups Displayed SELECT Name, State FROM Student GROUP BY State HAVING Count (*) > 4;

© 2002 by Prentice Hall 19 Sub-Queries SELECT Name FROM Student WHERE SID IN (SELECT StudentNumber FROM Enrollment WHERE ClassName = ‘MIS445’);

© 2002 by Prentice Hall 20 Joining Tables SELECT Student.SID, Student.Name, Enrollment.ClassName FROM Student, Enrollment WHERE Student.SID = Enrollment.StudentNumber AND Student.State = ‘OH’;

© 2002 by Prentice Hall 21 EXISTS SELECT DISTINCT StudentNumber FROM Enrollment A WHERE EXISTS (SELECT * FROM Enrollment B WHERE A.StudentNumber = B.StudentNumber AND A.ClassName NOT = B.ClassName);

© 2002 by Prentice Hall 22 Inputting Data INSERT INTO Enrollment VALUES (400, ‘MIS445’, 44);

© 2002 by Prentice Hall 23 Deleting Data DELETE Student WHERE Student.SID = 100;

© 2002 by Prentice Hall 24 Modifying Data UPDATE Enrollment SET SeatNumber = 44 WHERE SID = 400;

© 2002 by Prentice Hall 25 David M. Kroenke Database Processing Eighth Edition Chapter 9 Structured Query Language