Web Systems & Technologies

Slides:



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

1ISM - © 2010 Houman Younessi Lecture 3 Convener: Houman Younessi Information Systems Spring 2011.
DAT702.  Standard Query Language  Ability to access and manipulate databases ◦ Retrieve data ◦ Insert, delete, update records ◦ Create and set permissions.
Structured Query Language(SQL) XU Yinqing SEEM PHD YEAR 3.
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.
ASP.NET Programming with C# and SQL Server First Edition
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.
INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.
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.
Introduction to MySQL Lab no. 10 Advance Database Management System.
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.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
NMED 3850 A Advanced Online Design January 12, 2010 V. Mahadevan.
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
1 Structured Query Language (SQL). 2 Contents SQL – I SQL – II SQL – III SQL – IV.
SQL Unit – 2 Base Knowledge Presented By Mr. R.Aravindhan.
DAT602 Database Application Development Lecture 3 Review of SQL Language.
1 DBS201: Introduction to Structure Query Language (SQL) Lecture 1.
SQL Basics. What is SQL? SQL stands for Structured Query Language. SQL lets you access and manipulate databases.
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.
CIS 375—Web App Dev II SQL. 2 Introduction SQL (Structured _______ Language) is an ANSI standard language for accessing databases.ANSI SQL can execute.
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
Visual Programing SQL Overview Section 1.
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,
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
CHAPTER 9 SQL อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา 1.
>> Introduction to MySQL. Introduction Structured Query Language (SQL) – Standard Database Language – Manage Data in a DBMS (Database Management System)
Chapter 11 Database and SQL. Flat Files and Databases Flat files Databases Advantages Efficient use of resources Access control Disadvantages Security.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 6 CGI/Perl and databases.
Database: SQL, MySQL, LINQ and Java DB © by Pearson Education, Inc. All Rights Reserved.
IS6146 Databases for Management Information Systems Lecture 3: SQL III – The DDL Rob Gleasure robgleasure.com.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
ADVANCED SQL.  The SQL ORDER BY Keyword  The ORDER BY keyword is used to sort the result-set by one or more columns.  The ORDER BY keyword sorts the.
Programming for the Web MySQL Command Line Using PHP with MySQL Dónal Mulligan BSc MA
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.
LEC-8 SQL. Indexes The CREATE INDEX statement is used to create indexes in tables. Indexes allow the database application to find data fast; without reading.
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.
Rob Gleasure robgleasure.com
Module T03d Software Engineering
From: SQL From:
CHAPTER 7 DATABASE ACCESS THROUGH WEB
Chapter 5 Introduction to SQL.
Query Methods Where Clauses Start ….
Rob Gleasure robgleasure.com
Query Methods Where Clauses Start ….
CS320 Web and Internet Programming SQL and MySQL
Introduction to Structured Query Language(SQL)
ISC440: Web Programming 2 Server-side Scripting PHP 3
SQL Tutorial.
Chapter 8 Working with Databases and MySQL
Structured Query Language
Introduction To Structured Query Language (SQL)
Access: SQL Participation Project
SQL Queries Chapter No 3.
SQL.
Introduction To Structured Query Language (SQL)
Structured Query Language
CS3220 Web and Internet Programming SQL and MySQL
SQL Tutorial w3schools.
Presentation transcript:

Web Systems & Technologies CS-3548 Prepared By: Junaid Hassan Lecturer at UOS M.B.Din Campus junaidte14@gmail.com

Topic: Introduction to SQL

SQL Intro: SQL is a standard language for storing, manipulating and retrieving data in databases. SQL stands for Structured Query Language SQL can execute queries against a database SQL can retrieve data from a database SQL can insert records in a database SQL can create, update, delete records in a database SQL can create new databases To build a web site that shows data from a database, you will need: an RDBMS database program (i.e. MS Access, SQL Server, MySQL) and a server-side scripting language, like PHP or ASP

SQL Intro: RDBMS stands for Relational Database Management System. RDBMS is the basis for SQL, and for all modern database systems such as MS SQL Server, IBM DB2, Oracle, MySQL, and Microsoft Access. The data in RDBMS is stored in database objects called tables. A table is a collection of related data entries and it consists of columns and rows. A field is a column in a table that is designed to maintain specific information about every record in the table. A record, also called a row, is each individual entry that exists in a table.

SQL Syntax: A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or "Orders"). Tables contain records (rows) with data.

SQL Syntax: Most of the actions you need to perform on a database are done with SQL statements. The following SQL statement selects all the records in the "Customers" table: SELECT * FROM Customers;

SQL Syntax: Some Important SQL commands: SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index

SQL SELECT: The SELECT statement is used to select data from a database. The data returned is stored in a result table, called the result-set. SELECT column1, column2, ... FROM table_name; Here, column1, column2, ... are the field names of the table you want to select data from. If you want to select all the fields available in the table, use the following syntax: SELECT * FROM table_name;

SQL SELECT DISTINCT: Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values. The SELECT DISTINCT statement is used to return only distinct (different) values. SELECT DISTINCT column1, column2, ... FROM table_name; SELECT DISTINCT Country FROM Customers;

SQL WHERE: The WHERE clause is used to filter records. The WHERE clause is used to extract only those records that fulfill a specified condition. SELECT column1, column2, ... FROM table_name WHERE condition; SELECT * FROM Customers WHERE Country='Mexico'; SELECT * FROM Customers WHERE CustomerID=1;

SQL AND, OR, NOT: The WHERE clause can be combined with AND, OR, and NOT operators. The AND and OR operators are used to filter records based on more than one condition: The AND operator displays a record if all the conditions separated by AND is TRUE. The OR operator displays a record if any of the conditions separated by OR is TRUE. The NOT operator displays a record if the condition(s) is NOT TRUE.

SQL AND, OR, NOT: SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...; SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...; SELECT column1, column2, ... FROM table_name WHERE NOT condition; SELECT * FROM Customers WHERE NOT Country='Germany'; SELECT * FROM Customers WHERE Country='Germany' AND (City='Berlin' OR City='München');

SQL ORDER BY: The ORDER BY keyword is used to sort the result-set in ascending or descending order. The ORDER BY keyword sorts the records in ascending order by default. To sort the records in descending order, use the DESC keyword. SELECT column1, column2, ... FROM table_name ORDER BY column1, column2, ... ASC|DESC; SELECT * FROM Customers ORDER BY Country DESC; SELECT * FROM Customers ORDER BY Country ASC, CustomerName DESC;

SQL INSERT INTO: The INSERT INTO statement is used to insert new records in a table. INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...); If you are adding values for all the columns of the table, you do not need to specify the column names in the SQL query. However, make sure the order of the values is in the same order as the columns in the table. The INSERT INTO syntax would be as follows: INSERT INTO table_name VALUES (value1, value2, value3, ...); INSERT INTO Customers (CustomerName, ContactName, Address, City, PostalCode, Country) VALUES ('Cardinal', 'Tom B. Erichsen', 'Skagen 21', 'Stavanger', '4006', 'Norway');

SQL UPDATE: The UPDATE statement is used to modify the existing records in a table. UPDATE table_name SET column1 = value1, column2 = value2, ... WHERE condition; UPDATE Customers SET ContactName = ‘Junaid', City= ‘M.B.Din' WHERE CustomerID = 1;

SQL DELETE: The DELETE statement is used to delete existing records in a table. DELETE FROM table_name WHERE condition; DELETE FROM Customers WHERE CustomerName=‘junaid'; It is possible to delete all rows in a table without deleting the table. This means that the table structure, attributes, and indexes will be intact: DELETE * FROM table_name;

SQL CREATE DATABASE: The CREATE DATABASE statement is used to create a new SQL database. Syntax: CREATE DATABASE databasename; CREATE DATABASE testDB; We can also create database using PhpMyAdmin / cPanel

SQL DROP DATABASE: The DROP DATABASE statement is used to drop an existing SQL database. Syntax: DROP DATABASE databasename; Example: DROP DATABASE testDB;

SQL CREATE TABLE: The CREATE TABLE statement is used to create a new table in a database. CREATE TABLE table_name (     column1 datatype,     column2 datatype,     column3 datatype,    .... ); CREATE TABLE Persons (     PersonID int,     LastName varchar(255),     FirstName varchar(255),     Address varchar(255),     City varchar(255)  );

SQL DROP TABLE: The DROP TABLE statement is used to drop an existing table in a database. Syntax: DROP TABLE table_name; Example: DROP TABLE Shippers; The TRUNCATE TABLE statement is used to delete the data inside a table, but not the table itself: TRUNCATE TABLE table_name;

SQL ALTER TABLE: The ALTER TABLE statement is used to add, delete, or modify columns in an existing table. The ALTER TABLE statement is also used to add and drop various constraints on an existing table. ALTER TABLE table_name ADD column_name datatype; ALTER TABLE table_name DROP COLUMN column_name; ALTER TABLE table_name MODIFY COLUMN column_name datatype;

References: www.w3schools.com/sql