SQL Tutorials To understand some of the topics please analyze the following tutorials: The following tutorials will help:

Slides:



Advertisements
Similar presentations
Structured Query Language (SQL)
Advertisements

Chapter 4 Joining Multiple Tables
Virtual training week 4 structured query language (SQL)
Introduction to Structured Query Language (SQL)
IS 4420 Database Fundamentals Chapter 8: Advanced SQL Leon Chen
1 SQL-Structured Query Language SQL is the most common language used for creating and querying relational databases. Many users can access a database applications.
Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data
1 Creating a Non-Conditional List A- What are you going to do? You will “list” “all of the records” in a database. (it means you will not use any condition!)
Introduction to Structured Query Language (SQL)
Microsoft Access 2010 Chapter 7 Using SQL.
INFORMATION TECHNOLOGY IN BUSINESS AND SOCIETY SESSION 16 – SQL SEAN J. TAYLOR.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
Using SQL Queries to Insert, Update, Delete, and View Data Date Retrieval from a single table & Calculations © Abdou Illia MIS Spring 2015.
Relational DBs and SQL Designing Your Web Database (Ch. 8) → Creating and Working with a MySQL Database (Ch. 9, 10) 1.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Constraints  Constraints are used to enforce rules at table level.  Constraints prevent the deletion of a table if there is dependencies.  The following.
1 Chapter 8: Advanced SQL. Chapter 8 2 Processing Multiple Tables – Joins Join – a relational operation that causes two or more tables with a common domain.
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.
Using Special Operators (LIKE and IN)
1 © Prentice Hall, 2002 Chapter 8: Advanced SQL Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B. Prescott, Fred R. McFadden.
Modern Database Management Chapter 8: Advanced SQL.
Chapter 4Introduction to Oracle9i: SQL1 Chapter 4 Joining Multiple Tables.
6 1 Lecture 8: Introduction to Structured Query Language (SQL) J. S. Chou, P.E., Ph.D.
Topic 1: Introduction to SQL. SQL stands for Structured Query Language. SQL is a standard computer language for accessing and manipulating databases SQL.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
SQL LANGUAGE and Relational Data Model TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
SqlExam1Review.ppt EXAM - 1. SQL stands for -- Structured Query Language Putting a manual database on a computer ensures? Data is more current Data is.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
SQL SELECT Getting Data from the Database. Basic Format SELECT, FROM WHERE (=, >, LIKE, IN) ORDER BY ; SELECT LastName, FirstName, Phone, City FROM Customer.
© 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.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
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.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
MySQL Tutorial. Databases A database is a container that groups together a series of tables within a single structure Each database can contain 1 or more.
Copyright © 2016 Pearson Education, Inc. CHAPTER 7: ADVANCED SQL (PART I) Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki.
Lec-7. The IN Operator The IN operator allows you to specify multiple values in a WHERE clause. SQL IN Syntax SELECT column_name(s) FROM table_name WHERE.
Chapter 8 1 Lecture Advanced SQL. Chapter 8 2 Processing Multiple Tables–Joins Join – a relational operation that causes two or more tables with.
COM621: Advanced Interactive Web Development Lecture 11 MySQL – Data Manipulation Language.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
How to: SQL By: Sam Loch.
CHAPTER 7 DATABASE ACCESS THROUGH WEB
SQL Query Getting to the data ……..
Structured Query Language
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
Structured Query Language – The Basics
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
CHAPTER 7: ADVANCED SQL.
SQL Tutorial.
CHAPTER 6: INTRODUCTION TO SQL
Prof: Dr. Shu-Ching Chen TA: Yimin Yang
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
SQL LANGUAGE and Relational Data Model TUTORIAL
Prof: Dr. Shu-Ching Chen TA: Haiman Tian
Introduction To Structured Query Language (SQL)
Structured Query Language – The Fundamentals
Introduction To Structured Query Language (SQL)
Lesson 3 Chapter 10.
Presentation transcript:

SQL

Tutorials To understand some of the topics please analyze the following tutorials: The following tutorials will help:

What can we do with SQL Querying Data Single Table Multiple Tables Inserting Data Updating Data Deleting Data

Querying Data Querying Single Tables Basic Query Format Search Conditions Querying Multiple Tables

Querying Single Tables Basic Format: SELECT column(s) FROM table WHERE condition(s) Rules: SELECT must be first clause FROM must be second clause table/column names must be spelled as in the database

Selecting All Rows SELECT column(s) FROM table; Example: SELECT Customer_IDFROM Order_t;

Selecting Unique Rows SELECT DISTINCT column(s) FROM table; Example: SELECT DISTINCT Customer_ID FROM Order_t;

Search Conditions For retrieving specific rows: Comparison Operators Boolean Operators Other Operators Wildcards Expressions Functions Nulls SELECT column(s) FROM table WHERE ;

Comparison Operators SELECT Order_ID, Order_Date FROM Order_t WHERE Customer_ID = 1;

Comparison Operators, con’t... Comparison Operators: =equal to >greater than <less than >=greater than or equal to <=less than or equal to <>not equal to

Boolean Operators ANDall search conditions must be met ORany search condition must be met NOTa search condition must not be met SELECT Customer_ID, Order_ID, Order_Date FROM Order_t WHERE (Customer_ID = 1) AND (Order_ID > 1005);

Other Operators BETWEEN The BETWEEN... AND operator selects an inclusive range of data between two values. These values can be numbers, text, or dates. SELECT Customer_ID, Order_Date FROM Order_t WHERE Customer_ID BETWEEN 1 AND 5;

Wildcards * SELECT * FROM Order_t WHERE Customer_ID IN (1, 3, 5) You can use a "*" to select all columns. LIKE Like is a very powerful operator that allows you to select only rows that are "like" what you specify. The percent sign "%" can be used as a wild card to match any possible character that might appear before or after the characters specified. SELECT Customer_Name, Customer_ID FROM Customer_t WHERE Customer_Name LIKE (‘%furn%’); SELECT Customer_Name, Customer_ID FROM Customer_t WHERE Customer_Name LIKE (‘%furn_____’);

Min and Max Finds minimum/maximum value of attribute SELECT MAX(Order_Date) FROM Order_t; SELECT MIN(Order_Date) FROM Order_t WHERE Customer_ID > 8;

Nulls Means: unknown not applicable SELECT Customer_Name FROM Customer_t WHERE Customer_address IS NULL;

Querying Multiple Tables Joins Brings data together from multiple tables Same column in multiple tables Use table_name.column_name to distinguish columns Use WHERE clause to join tables Example SELECT Customer_t.Customer_ID, Customer_t. Customer_Name, Order_date FROM Customer_t, Order_t WHERE Order_date > (‘11/01/98’,’MM/DD/YY’) AND Customer_t.Customer_ID = Order_t.Customer_ID; ****Notice that the Customer_ID is the primary Key for Customer_t and Foreign key for order_t table**** This is the only way you can connect two tables !!!

Inserting Data INSERT INTO table_name [(column1_name, column2_name, …)] VALUES (column1_value, column2_value, …); Examples: INSERT INTO Order_t (order_id, customer_id) VALUES (9000,8);

Updating Data UPDATE table_name SET column1_name = new_value [,column2_name = new value,…] WHERE condition(s); Example: UPDATE Order_t SET Customer_ID = 2 WHERE Customer_ID = 1;

Deleting Data DELETE FROM table_name [WHERE condition(s)]; Examples: DELETE FROM Order_t WHERE Customer_ID = 2;