Structured Query Language (SQL)

Slides:



Advertisements
Similar presentations
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)MySQL Recap.
Advertisements

Copyright © by Royal Institute of Information Technology Introduction To Structured Query Language (SQL) 1.
This course has taken from This unique introductory SQL tutorial not only provides easy-to-understand SQL instructions, but it allows.
30-Jun-15 SQL A Brief Introduction. SQL SQL is Structured Query Language Some people pronounce SQL as “sequel” Other people insist that only “ess-cue-ell”
From VS C# 2010 Programming, John Allwork 1 VS2010 C# Programming - DB intro 1 Topics – Database Relational - linked tables SQL ADO.NET objects Referencing.
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
CPS120: Introduction to Computer Science Information Systems: Database Management Nell Dale John Lewis.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
2440: 141 Web Site Administration Database Management Using SQL Professor: Enoch E. Damson.
CS 174: Web Programming September 23 Class Meeting Department of Computer Science San Jose State University Fall 2015 Instructor: Ron Mak
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting MySQL – Selecting Data.
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
DAT602 Database Application Development Lecture 3 Review of SQL Language.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
# 1# 1 Creating Tables, Setting Constraints, and Datatypes What is a constraint and why do we use it? What is a datatype? What does CHAR mean? CS 105.
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,
Databases Letts Chapter 11. A database program can be used to:  sort a file into a different order;  search through the records for a matching string.
SQL SELECT Getting Data from the Database. Basic Format SELECT, FROM WHERE (=, >, LIKE, IN) ORDER BY ; SELECT LastName, FirstName, Phone, City FROM Customer.
Understand Primary, Foreign, and Composite Keys Database Administration Fundamentals LESSON 4.2.
WEEK# 12 Haifa Abulaiha November 02,
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
# 1# 1 QueriesQueries How do we ask questions of the data? What is SELECT? What is FROM? What is WHERE? What is a calculated field? Spring 2010 CS105.
Manipulating Data Lesson 3. Objectives Queries The SELECT query to retrieve or extract data from one table, how to retrieve or extract data by using.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 5: SQL I Rob Gleasure robgleasure.com.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
SQL Definition: Structured Query Language An industry-standard language for creating, updating and, querying relational database management systems.relational.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Understand Data Definition Language (DDL) Database Administration Fundamentals LESSON 1.4.
 MySQL  DDL ◦ Create ◦ Alter  DML ◦ Insert ◦ Select ◦ Update ◦ Delete  DDL(again) ◦ Drop ◦ Truncate.
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.
SQL SQL Ayshah I. Almugahwi Maryam J. Alkhalifa
Fundamentals of DBMS Notes-1.
How to: SQL By: Sam Loch.
GCSE COMPUTER SCIENCE Data 2.4 Databases & SQL.
Web Systems & Technologies
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
CS320 Web and Internet Programming SQL and MySQL
3.5 Databases Relationships.
Prepared by : Moshira M. Ali CS490 Coordinator Arab Open University
 2012 Pearson Education, Inc. All rights reserved.
Understand Data Manipulation Language (DML)
Understand Data Manipulation Language (DML)
MIS2502: Data Analytics SQL – Putting Information Into a Database
Structured Query Language (SQL) William Klingelsmith
Lecturer: Mukhtar Mohamed Ali “Hakaale”
DB Implementation: MS Access Queries
Introduction To Structured Query Language (SQL)
MIS2502: Data Analytics SQL – Putting Information Into a Database
Structured Query Language – The Fundamentals
Introduction To Structured Query Language (SQL)
CS3220 Web and Internet Programming SQL and MySQL
MIS2502: Data Analytics SQL 4– Putting Information Into a Database
MySQL Database System Installation Overview SQL summary
CS3220 Web and Internet Programming SQL and MySQL
The University of Akron College of Applied Science & Technology Dept
MySQL Database System Installation Overview SQL summary
Manipulating Data Lesson 3.
Database Instructor: Bei Kang.
SQL NOT NULL Constraint
SQL (Structured Query Language)
SQL AUTO INCREMENT Field
Presentation transcript:

Structured Query Language (SQL) A Level Only Photocopiable/digital resources may only be copied by the purchasing institution on a single site and for their own use © ZigZag Education, 2016

Structured Query Language Structured query language (SQL) is the language used to search databases. Here is an example of an SQL statement. SELECT FirstName FROM Student WHERE Gender = “Male” Fields to show The table Search criteria This statement selects the FirstName field from the Student table and only shows the male students. Consider this table: StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 3 Sarah Smith 60 Belsize Rd Female © ZigZag Education, 2016

Results SELECT FirstName FROM Student WHERE Gender = “Male” StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 3 Sarah Smith 60 Belsize Rd Female SELECT FirstName FROM Student WHERE Gender = “Male” Fields to show The table Search criteria These are the results of the query. FirstName John Ben © ZigZag Education, 2016

Comparison Operators The following comparison operators are used in SQL statements: Comparison operator Symbol Equal to = Less than < Greater than > Less than or equal to <= Greater than or equal to >= Not equal to <> © ZigZag Education, 2016

Combining Conditions SELECT FirstName FROM Student StudentID FirstName LastName TestScore Gender 1 John Curtis 55 Male 2 Ben Jackson 75 3 Sarah Smith 80 Female We can use the AND operator to combine conditions. SELECT FirstName FROM Student WHERE Gender = “Male” AND TestScore >= 75 These are the results of the query. TestScore Ben © ZigZag Education, 2016

Inserting a Record A new record can be added to a table using the INSERT command. INSERT INTO Student VALUES (4, “Eloise”, “Roberts”, “9 Baynes Mews”, “Female”) StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 3 Sarah Smith 60 Belsize Rd Female 4 Eloise Roberts 9 Baynes Mews © ZigZag Education, 2016

Deleting a Record DELETE FROM Student WHERE StudentID = 3 Records can be deleted from a table using the DELETE command. DELETE FROM Student WHERE StudentID = 3 StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 3 Sarah Smith 60 Belsize Rd Female 4 Eloise Roberts 9 Baynes Mews StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 4 Eloise Roberts 9 Baynes Mews Female © ZigZag Education, 2016

Updating a Record UPDATE Student SET Address = “45 Cleveland Rd” Records can be updated using the UPDATE command. UPDATE Student SET Address = “45 Cleveland Rd” WHERE StudentID = 2 StudentID FirstName LastName Address Gender 1 John Curtis 12 Brook Lane Male 2 Ben Jackson 1 Totters Lane 4 Eloise Roberts 9 Baynes Mews Female 45 Cleveland Rd © ZigZag Education, 2016

Multiple Tables SELECT FirstName, LastName, Title, TeacherName Data can be retrieved from multiple tables using an SQL statement. SELECT FirstName, LastName, Title, TeacherName FROM Student, Teacher WHERE Student.TeacherID = Teacher.TeacherID StudentID FirstName LastName TeacherID 001 Alex Bennett 002 James Hadwen 003 Eloise Roberts 004 Patrick Dua-Brown TeacherID Title TeacherName 001 Mr Smith 002 Ford 003 Mrs Patel 004 Miss Wright A linking condition is used to join the two tables together. Dot notation is used to specify which table a field is in. © ZigZag Education, 2016

Sorting Results SELECT FirstName FROM Student WHERE Gender = “Male” The results of a query can be sorted using the ORDER BY command. SELECT FirstName FROM Student WHERE Gender = “Male” ORDER BY LastName This will order the results by the students’ last names in ascending order. © ZigZag Education, 2016

Creating a Table CREATE TABLE Student ( A new table can be created using the CREATE TABLE command. CREATE TABLE Student ( StudentID INT PRIMARY KEY NOT NULL FirstName VARCHAR(20) LastName VARCHAR(20) Gender VARCHAR(1) ) NOT NULL means the field can’t be left blank. VARCHAR is a string with a variable length; the maximum length is the value in the brackets. © ZigZag Education, 2016

END