SQL SQL Ayshah I. Almugahwi 200800180 Maryam J. Alkhalifa 200801068.

Slides:



Advertisements
Similar presentations
SQL – Lesson II Grade 12.
Advertisements

Basic SQL Introduction Presented by: Madhuri Bhogadi.
Virtual training week 4 structured query language (SQL)
Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
Introduction to Structured Query Language (SQL)
SQL SQL stands for Structured Query Language SQL allows you to access a database SQL is an ANSI standard computer language SQL can execute queries against.
Structured Query Language Part I Chapter Three CIS 218.
1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
SQL Intermediate Workshop Authored by Jay Mussan-Levy.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
Agenda TMA01 M876 Block 3 – Using SQL Structured Query Language - SQL A non-procedural language to –Create database and relation structures. –Perform.
Lecture6:Data Manipulation in SQL, Simple SQL queries Prepared by L. Nouf Almujally Ref. Chapter5 Lecture6 1.
SQL: Data Manipulation Presented by Mary Choi For CS157B Dr. Sin Min Lee.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
1 TAC2000/ Protocol Engineering and Application Research Laboratory (PEARL) Structured Query Language Introduction to SQL Structured Query Language.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Using Special Operators (LIKE and IN)
Getting to Know SQL. © Jim Hope 2002 All Rights Reserved Data Manipulation SELECT statement INSERT INTO statement UPDATE statement DELETE statement TRANSFORM.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 7 Introduction to Structured Query Language (SQL)
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Nikolay Kostov Telerik Corporation
SQL. คำสั่ง SQL SQL stands for Structured Query Language is a standard language for accessing and manipulating databases.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Fox MIS Spring 2011 Database Week 5 SQL basics SELECT, INSERT, UPDATE, DELETE.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
SQL Jan 20,2014. DBMS Stores data as records, tables etc. Accepts data and stores that data for later use Uses query languages for searching, sorting,
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
DATA RETRIEVAL WITH SQL Goal: To issue a database query using the SELECT command.
1 SQL SQL (Structured Query Language) : is a database language that is used to create, modify and update database design and data. Good Example of DBMS’s.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 (Part II) INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor.
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.
ITEC 3220A Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220a.htm
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.
SQL LANGUAGE TUTORIAL Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha.
SQL: Structured Query Language It enables to create and operate on relational databases, which are sets of related information stored in tables. It is.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
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.
Teacher Workshop Database Design Pearson Education © 2014.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
SQL Query Getting to the data ……..
Chapter 5 Introduction to SQL.
Prof: Dr. Shu-Ching Chen TA: Hsin-Yu Ha
Introduction to Structured Query Language(SQL)
The Database Exercises Fall, 2009.
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
Database systems Lecture 3 – SQL + CRUD
Access: SQL Participation Project
SQL Queries Chapter No 3.
Structured Query Language – The Fundamentals
Introduction To Structured Query Language (SQL)
Structured Query Language
Shelly Cashman: Microsoft Access 2016
Presentation transcript:

SQL SQL Ayshah I. Almugahwi 200800180 Maryam J. Alkhalifa 200801068

Introduction to sql What is SQL? What can SQL do? - SQL stands for Structured Query Language - SQL is a special-purpose language used to define, access, and manipulate data - It has special rules of grammar (syntax and semantics) What can SQL do? - SQL can execute queries SQL can retrieve data from a database - SQL can insert, update, and delete records in a database - SQL can create new tables in a database

Sql Commands The SQL language includes two distinct sets of commands: Data Definition Language DDL Data Manipulation Language DML includes numerous commands for handling specific tasks such as: Create indexes Views Constraints Drop Alter comprised of just five statements : INSERT UPDATE DELETE MERGE SELECT

Select Statement Syntax: Example: - used to query the database and retrieve selected data that match the criteria that you specify. Syntax: SELECT [ALL | DISTINCT] column1[,column2] FROM table1[,table2] [WHERE "conditions"] [GROUP BY "column-list"] [HAVING "conditions] [ORDER BY "column-list" [ASC | DESC] ]; Example: SELECT name, age, salary FROM employee WHERE age > 50; Remember to put a semicolon at the end of your SQL statements. it indicates that your SQL statement is complete and is ready to be executed

Select Statement (cont.) Comparison Operator: Sign Name > Greater than < Less than >= Greater than or equal to <= Less than or equal to <> Or != Not equal to LIKE String comparison test

Select Statement (cont.) Example for LIKE: SELECT name, title, dept FROM employee WHERE title LIKE 'Pro%'; LIKE in Access: LIKE [Enter the first char to search by: ] & "*" -or- LIKE "*" & [Enter any char to search by: ] & "*“ Example: SELECT F_name, L_name, age, salary FROM employee WHERE F_name LIKE [A] & "*" -or- WHERE F_name LIKE "*" & [A] & "*“;

Functions Example 1: Example 2: Function Description MIN returns the smallest value in a given column MAX returns the largest value in a given column AVG returns the average value of a given column SUM returns the sum of the numeric values in a given column COUNT returns the total number of values in a given column Example 1: Example 2: SELECT AVG(salary) FROM employee; SELECT AVG(salary) FROM employee WHERE title = 'Programmer';

Group By statement Syntax: Example: - Gather all of the rows together that contain data in the specified column(s) and will allow aggregate functions to be performed on the one or more columns. Syntax: SELECT column1, SUM(column2) FROM "list-of-tables" GROUP BY "column-list"; Example: SELECT max(salary), dept FROM employee GROUP BY dept;

Having statement Syntax: Example: - Allows you to specify conditions on the rows for each group - in other words, which rows should be selected will be based on the conditions you specify. The HAVING clause should follow the GROUP BY clause if you are going to use it. Syntax: SELECT column1, SUM(column2) FROM "list-of-tables" GROUP BY "column-list" HAVING "condition"; Example: SELECT dept, avg(salary) FROM employee GROUP BY dept HAVING avg(salary) > 20000;

Order by statement Syntax: Example: - ORDER BY is an optional clause which will allow you to display the results of your query in a sorted order (either ascending order or descending order) based on the columns that you specify to order by. Syntax: SELECT column1 FROM "list-of-tables" ORDER BY "column-list" [ASC | DESC]; Example: SELECT employee_id, dept, name, age, salary FROM employee_info WHERE dept = 'Sales‘ ORDER BY salary DESC;

Combining conditions And & or operator s Syntax: Example: - The AND and OR operator can be used to join two or more conditions in the WHERE clause. Syntax: SELECT column1, SUM(column2) FROM "list-of-tables" WHERE "condition1" AND "condition2"; Example: SELECT employeeid, firstname, lastname, title, salary FROM employee_info WHERE salary >= 50000.00 AND title = 'Programmer'; you can use parenthesis around your conditional expressions to make it easier to read but they are not required

Between operator Syntax: Example: - The BETWEEN conditional operator is used to test to see whether or not a value is "between" two other values. Syntax: SELECT col1, col2 FROM table WHERE value BETWEEN value AND value; Example: SELECT employeeid, age, lastname, salary FROM employee_info WHERE age BETWEEN 30 AND 40;

Insert Into Statement Syntax: Example: - The INSERT INTO statement is used to insert a new row in a table Syntax: INSERT INTO table_name VALUES (value1, value2, value3,...) Example: INSERT INTO Persons VALUES (4,'Nilsen', 'Johan', 'Bakken 2', 'Stavanger')

Up date statement Syntax: Example: - The UPDATE statement is used to update existing records in a table. Syntax: UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Example: UPDATE Persons SET Address='Nissestien 67', City='Sandnes' WHERE LastName='Tjessem' AND FirstName='Jakob‘ - Be careful when updating records. If we omitted the WHERE clause in the previous example all the values of address and city column will be the same.

Table joins Syntax: Example: - The "Join" makes relational database systems "relational". Syntax: SELECT "list-of-columns" FROM [table1] INNER JOIN [table2] ON [table1].Primary KEY=[table2].Foreign Key WHERE "search-condition(s)“ Example: SELECT [customer_info] .Firstname, [customer_info] . Lastname, [purchases].item FROM [customer_info] INNER JOIN [purchases] ON [customer_info] .CustomerID= [purchases] . CustomerID WHERE “[customer_info.]. CustomerID = 12345”;

References: SQL Couse.com, Interactive Online SQL Training (http://www.sqlcourse2.com/intro2.html) W3 School, Introduction SQL (http://www.w3schools.com/sql/sql_intro.asp)

Thank You For Listening