Selecting Data 98-364 Database Administration Fundamentals LESSON 3.1a.

Slides:



Advertisements
Similar presentations
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Advertisements

Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Structured Query Language Part I Chapter Three CIS 218.
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.
Ceng 356-Lab2. Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the.
Rationale Aspiring Database Developers should be able to efficiently query and maintain databases. This module will help students learn the Structured.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Chapter 10 Queries and Updating Part C. SQL Copyright 2005 Radian Publishing Co.
CHAPTER 7 Database: SQL, MySQL. Topics  Introduction  Relational Database Model  Relational Database Overview: Books.mdb Database  SQL (Structured.
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 stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Sundara Ram Matta Apr 01 st, Sundara Ram Matta Apr 01 st, 2015
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Restricting and Sorting Data. ◦ Limiting rows with:  The WHERE clause  The comparison conditions using =,
2 Copyright © Oracle Corporation, All rights reserved. Restricting and Sorting Data.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
4 Copyright © 2006, Oracle. All rights reserved. Restricting and Sorting Data.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
SQL SQL Server : Overview SQL : Overview Types of SQL Database : Creation Tables : Creation & Manipulation Data : Creation & Manipulation Data : Retrieving.
Chapter 10: The Data Tier We discuss back-end data storage for Web applications, relational data, and using the MySQL database server for back-end storage.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
SQL. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
2 第二讲 Restricting and Sorting Data. Objectives After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Advanced Repetition Structure and String Functions (Unit 10) Visual Basic for Applications.
Understand Tables and How to Create Them Database Administration Fundamentals LESSON 2.2.
Session 9 Accessing Data from a Database. RDBMS and Data Management/ Session 9/2 of 34 Session Objectives Describe the SELECT statement, its syntax and.
2 Copyright © 2009, Oracle. All rights reserved. Restricting and Sorting Data.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
Introduction to Database SEM I, AY Department of Information Technology Salalah College of Technology Chapter No.3 SQL.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
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.
Create Views Using a Graphical Designer Database Administration Fundamentals LESSON 2.3b.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
Select Complex Queries Database Management Fundamentals LESSON 3.1b.
Tarik Booker CS 122. What we will cover… Tables (review) SELECT statement DISTINCT, Calculated Columns FROM Single tables (for now…) WHERE Date clauses,
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
 MySQL is a database system used on the web  MySQL is a database system that runs on a server  MySQL is ideal for both small and large applications.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
SQL Query Getting to the data ……..
Writing Basic SQL SELECT Statements
 2012 Pearson Education, Inc. All rights reserved.
Introduction to Structured Query Language(SQL)
LESSON 3.1a Database Administration Fundamentals Selecting Data.
Understand Data Manipulation Language (DML)
JDBC.
Understand Data Manipulation Language (DML)
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Introduction To Structured Query Language (SQL)
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall
Access: SQL Participation Project
HAVING,INDEX,COMMIT & ROLLBACK
Introduction To Structured Query Language (SQL)
Section 4 - Sorting/Functions
SQL Tutorial Basic SQL Commands
Introduction to SQL Server and the Structure Query Language
Presentation transcript:

Selecting Data Database Administration Fundamentals LESSON 3.1a

Database Administration Fundamentals LESSON 3.1a Lesson Overview In this lesson, you will learn:  SELECT  DISTINCT  WHERE  ORDER BY  The basic logical operators AND and OR  Truth tables

Database Administration Fundamentals LESSON 3.1a SELECT  The SELECT statement is used to select data from a database.  It can retrieve data from one or more tables, temporary tables, or views.  The selection is stored in a result table, called the result set.  SELECT is the most commonly used data manipulation language (DML) command Remember this example used in Review Lesson 1.3: SELECT column_name(s) FROM table_name WHERE conditional Example: SELECT * FROM Grant_info WHERE aid_awarded > Yields students from the Grant_info table who awarded more than $36,000.

Database Administration Fundamentals LESSON 3.1a SELECT DISTINCT  Some of the fields in a table may contain duplicate values.  DISTINCT can be used to return only unique values.  The first occurrence of the DISTINCT data in the search is shown.  DISTINCT returns only distinct (unique) values. SELECT DISTINCT column_name(s) FROM table_name Example of SELECT DISTINCT: SELECT DISTINCT Teacher FROM table_Grades

Database Administration Fundamentals LESSON 3.1a SELECT DISTINCT (Continued) Table Grades TeacherHourSubjectGradeFee Smith1EnglishA0 Jones2MathB0 Smith3ScienceC0 Results from: SELECT DISTINCT Teacher FROM table_Grades Teacher Smith Jones

Database Administration Fundamentals LESSON 3.1a WHERE The WHERE clause is used to extract only those records that meet a specified set of criteria. WHERE—specifies which rows to retrieve. SELECT column_name(s) FROM table_name WHERE column_name = variable Example: SELECT * FROM Grant_info WHERE aid_awarded > Selects students who have been awarded more than $36,000 from the Grant_info table.

Database Administration Fundamentals LESSON 3.1a ORDER BY Sorts the result set by a specified column or the records in ascending (ASC) order (by default) or descending order (DESC). ORDER BY—specifies an order in which to return the rows. SELECT column_name(s) FROM table_name ORDER BY column_name(s) ASC|DESC Example: SELECT * FROM table_grades ORDER BY teacher ASC

Database Administration Fundamentals LESSON 3.1a ORDER BY (continued) Results from: SELECT * FROM table_grades ORDER BY teacher ASC Results: TeacherHourSubjectGradeFee Jones2MathB0 Smith1EnglishA0 Vann3ScienceC0

Database Administration Fundamentals LESSON 3.1a Logical Operators: AND and OR Boolean operators  Designed to work with Boolean values of true or false.  Four most common Boolean operators in programming are AND (logical conjunction),OR (logical inclusion), XOR (exclusive OR), and NOT (logical negation).  Often used as qualifiers in database searches.  Example: teacher = “Smith” AND subject = “English”

Database Administration Fundamentals LESSON 3.1a Truth Tables  A truth table is made up of two columns with 1’s and 0’s or T’s and F’s for True or False. Logical And: Logical Or:  And = All items must be true to get a “True” result.  Or = Only one of the items must be true to get a “True” result.  The order of items has no influence on the result of a truth table.

Database Administration Fundamentals LESSON 3.1a AND Operator  Displays a record if both the first condition and the second condition are true. SELECT column_name FROM table_name WHERE column_name_1 = variable_1 AND column_name_2 = variable_2 Example: SELECT * FROM table_Grades WHERE teacher = “Smith” AND Grade = “A” This code returns one record from the grade table: Smith1EnglishA0

Database Administration Fundamentals LESSON 3.1a OR Operator  Displays a record if either the first condition or the second condition is true. SELECT column_name FROM table_name WHERE column_name_1 = variable_1 OR column_name_2 = variable_2 Example: SELECT * FROM table_Grades WHERE teacher = “Smith” OR Grade = “A” This logic returns the following records from the grade table: Smith1EnglishA0 Smith3ScienceC0

Database Administration Fundamentals LESSON 3.1a Lesson Review 1. What is the difference between AND and OR? 2. Write an SELECT example that arranges students’ letter grades in the table_grades in ascending order. 3. Write an SELECT example with a WHERE condition based upon data that might reside in a Scholarship_info table ?