SlideShare a Scribd company logo
1 of 12
Department of Information Technology 1Data base Technologies (ITB4201)
Introduction to
Structured Query Language (SQL) Part 2
Dr. C.V. Suresh Babu
Professor
Department of IT
Hindustan Institute of Science & Technology
Department of Information Technology 2Data base Technologies (ITB4201)
Action Plan
• SQL Introduction
• Simple Queries in SQL
• Quiz
Department of Information Technology 3Data base Technologies (ITB4201)
Database queries
• SELECT queries are used to extract information from a
database:
Example:
SELECT first_name, last_name
FROM president
WHERE state = ‘NY’;
Department of Information Technology 4Data base Technologies (ITB4201)
More database queries
• More examples
SELECT first_name, last_name
FROM president
WHERE birth_date like ’19%’;
SELECT count(*) FROM president
WHERE state = ‘VT’;
SELECT first_name, last_name
FROM president
WHERE state IN (ME,NH,VT,MA,CT,RI);
Department of Information Technology 5Data base Technologies (ITB4201)
How to create a DB table?
• Use CREATE TABLE query, specifying fields and column types:
Example:
CREATE TABLE friends (
first_name varchar(25),
last_name varchar(25),
gender enum(‘M’, ‘F’),
grade smallint unsigned,
hair_color varchar(20),
email varchar(30),
screen_name varchar(25),
phone char(12));
Department of Information Technology 6Data base Technologies (ITB4201)
Adding records to a table
• Use the INSERT query:
Example:
INSERT INTO friends VALUES (‘Daffy’,
‘Duck’,‘M’,11,’Brunette’,‘daffy@disney.com’,
YellowBill’, ’315-555-1213’);
Department of Information Technology 7Data base Technologies (ITB4201)
Editing records
• Use the UPDATE query:
Example:
UPDATE friends
SET phone=‘315-555-1234’
WHERE first_name=‘Daffy’ and
last_name = ‘Duck’;
Department of Information Technology 8Data base Technologies (ITB4201)
Deleting records from a table
• Use the DELETE query:
Example:
DELETE FROM friends
WHERE first_name=‘Daffy’ and last_name=‘Duck’;
Department of Information Technology 9Data base Technologies (ITB4201)
How to use a DB table?
• Finding a date:
SELECT first_name, screen_name, phone
FROM friends
WHERE gender=‘F’ and
grade > 10 and
hair_color=‘Red’;
Department of Information Technology 10Data base Technologies (ITB4201)
Tutorial https://www.techonthenet.com/sql/select.php
Department of Information Technology 11Data base Technologies (ITB4201)
Quiz
1. Which of the following SQL clauses is used to DELETE tuples from a database table?
a) DELETE
b) REMOVE
c) DROP
d) CLEAR
2. Which of the following is not a DDL command?
a) UPDATE
b) TRUNCATE
c) ALTER
d) None of the Mentioned
3. The command to remove rows from a table ‘CUSTOMER’ is __________________
a) DROP FROM CUSTOMER
b) UPDATE FROM CUSTOMER
c) REMOVE FROM CUSTOMER
d) DELETE FROM CUSTOMER WHERE
4. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with
an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’
5. SQL query to find all the cities whose humidity is 95.
a) SELECT city WHERE humidity = 95
b) SELECT city FROM weather WHERE humidity = 95
c) SELECT humidity = 89 FROM weather
d) SELECT city FROM weather
Department of Information Technology 12Data base Technologies (ITB4201)
Quiz Answers
1. Which of the following SQL clauses is used to DELETE tuples from a database table?
a) DELETE
b) REMOVE
c) DROP
d) CLEAR
2. Which of the following is not a DDL command?
a) UPDATE
b) TRUNCATE
c) ALTER
d) None of the Mentioned
3. The command to remove rows from a table ‘CUSTOMER’ is __________________
a) DROP FROM CUSTOMER
b) UPDATE FROM CUSTOMER
c) REMOVE FROM CUSTOMER
d) DELETE FROM CUSTOMER WHERE
4. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with
an “a”?
a) SELECT * FROM Persons WHERE FirstName=’a’
b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’
c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’
d) SELECT * FROM Persons WHERE FirstName=’%a%’
5. SQL query to find all the cities whose humidity is 95.
a) SELECT city WHERE humidity = 95
b) SELECT city FROM weather WHERE humidity = 95
c) SELECT humidity = 89 FROM weather
d) SELECT city FROM weather

More Related Content

What's hot

Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database conceptsTemesgenthanks
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-convertedgayaramesh
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapVikas Jagtap
 
DBMS presentation
DBMS presentationDBMS presentation
DBMS presentationcpjcollege
 
Object relationship mapping and hibernate
Object relationship mapping and hibernateObject relationship mapping and hibernate
Object relationship mapping and hibernateJoe Jacob
 
Unit 2 rdbms study_material
Unit 2  rdbms study_materialUnit 2  rdbms study_material
Unit 2 rdbms study_materialgayaramesh
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Rakibul Hasan Pranto
 
Object Oriented Database Management System
Object Oriented Database Management SystemObject Oriented Database Management System
Object Oriented Database Management SystemAjay Jha
 
Introduction of Database Design and Development
Introduction of Database Design and DevelopmentIntroduction of Database Design and Development
Introduction of Database Design and DevelopmentEr. Nawaraj Bhandari
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materialsgayaramesh
 
Placement oriented data structures
Placement oriented data structuresPlacement oriented data structures
Placement oriented data structuresLovelyn Rose
 
Introduction to ER Diagrams
Introduction to ER DiagramsIntroduction to ER Diagrams
Introduction to ER DiagramsAdri Jovin
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMSkoolkampus
 
Object database standards, languages and design
Object database standards, languages and designObject database standards, languages and design
Object database standards, languages and designDabbal Singh Mahara
 

What's hot (20)

Object oriented database concepts
Object oriented database conceptsObject oriented database concepts
Object oriented database concepts
 
Object oriented database
Object oriented databaseObject oriented database
Object oriented database
 
Unit 3 rdbms study_materials-converted
Unit 3  rdbms study_materials-convertedUnit 3  rdbms study_materials-converted
Unit 3 rdbms study_materials-converted
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
 
Odbms concepts
Odbms conceptsOdbms concepts
Odbms concepts
 
DBMS presentation
DBMS presentationDBMS presentation
DBMS presentation
 
Object relationship mapping and hibernate
Object relationship mapping and hibernateObject relationship mapping and hibernate
Object relationship mapping and hibernate
 
Unit 2 rdbms study_material
Unit 2  rdbms study_materialUnit 2  rdbms study_material
Unit 2 rdbms study_material
 
Oodbms ch 20
Oodbms ch 20Oodbms ch 20
Oodbms ch 20
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
Object Oriented Database Management System
Object Oriented Database Management SystemObject Oriented Database Management System
Object Oriented Database Management System
 
Introduction of Database Design and Development
Introduction of Database Design and DevelopmentIntroduction of Database Design and Development
Introduction of Database Design and Development
 
Unit1 rdbms study_materials
Unit1 rdbms study_materialsUnit1 rdbms study_materials
Unit1 rdbms study_materials
 
Placement oriented data structures
Placement oriented data structuresPlacement oriented data structures
Placement oriented data structures
 
Ordbms
OrdbmsOrdbms
Ordbms
 
Introduction to ER Diagrams
Introduction to ER DiagramsIntroduction to ER Diagrams
Introduction to ER Diagrams
 
Dbms models
Dbms modelsDbms models
Dbms models
 
Chapt 1 odbms
Chapt 1 odbmsChapt 1 odbms
Chapt 1 odbms
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
 
Object database standards, languages and design
Object database standards, languages and designObject database standards, languages and design
Object database standards, languages and design
 

Similar to SQL query Demo

Fp304 DATABASE SYSTEM JUNE 2012
Fp304   DATABASE SYSTEM JUNE 2012Fp304   DATABASE SYSTEM JUNE 2012
Fp304 DATABASE SYSTEM JUNE 2012Syahriha Ruslan
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxchristinemaritza
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfKeerthanaP37
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL) MuhammadWaheed44
 
Sample Question Paper IP Class xii
Sample Question Paper IP Class xii Sample Question Paper IP Class xii
Sample Question Paper IP Class xii kvs
 
Db2考试测试题
Db2考试测试题Db2考试测试题
Db2考试测试题fm2008
 
Advanced Database Systems - Presentation 2.pptx
Advanced Database Systems - Presentation 2.pptxAdvanced Database Systems - Presentation 2.pptx
Advanced Database Systems - Presentation 2.pptxEllenGracePorras
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptxEllenGracePorras
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docxjohniemcm5zt
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorialMohd Tousif
 
Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库renguzi
 
Sql intro
Sql introSql intro
Sql introglubox
 
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paper
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paperInformatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paper
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paperHarish Gyanani
 

Similar to SQL query Demo (20)

Fp304 DATABASE SYSTEM JUNE 2012
Fp304   DATABASE SYSTEM JUNE 2012Fp304   DATABASE SYSTEM JUNE 2012
Fp304 DATABASE SYSTEM JUNE 2012
 
T6
T6T6
T6
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
 
BCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdfBCS4L1-Database Management lab.pdf
BCS4L1-Database Management lab.pdf
 
Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)  Data Manipulation(DML) and Transaction Control (TCL)
Data Manipulation(DML) and Transaction Control (TCL)
 
Sample Question Paper IP Class xii
Sample Question Paper IP Class xii Sample Question Paper IP Class xii
Sample Question Paper IP Class xii
 
Db2考试测试题
Db2考试测试题Db2考试测试题
Db2考试测试题
 
Sample paper
Sample paperSample paper
Sample paper
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Sql
SqlSql
Sql
 
Rdbms day3
Rdbms day3Rdbms day3
Rdbms day3
 
Advanced Database Systems - Presentation 2.pptx
Advanced Database Systems - Presentation 2.pptxAdvanced Database Systems - Presentation 2.pptx
Advanced Database Systems - Presentation 2.pptx
 
Sql xp 01
Sql xp 01Sql xp 01
Sql xp 01
 
Structured Query Language (SQL).pptx
Structured Query Language (SQL).pptxStructured Query Language (SQL).pptx
Structured Query Language (SQL).pptx
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docx
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
SQL
SQLSQL
SQL
 
Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库
 
Sql intro
Sql introSql intro
Sql intro
 
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paper
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paperInformatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paper
Informatics practises 12th CBSE INDIA 2012-2013 MAIN EXAM paper
 

More from Dr. C.V. Suresh Babu (20)

Data analytics with R
Data analytics with RData analytics with R
Data analytics with R
 
Association rules
Association rulesAssociation rules
Association rules
 
Clustering
ClusteringClustering
Clustering
 
Classification
ClassificationClassification
Classification
 
Blue property assumptions.
Blue property assumptions.Blue property assumptions.
Blue property assumptions.
 
Introduction to regression
Introduction to regressionIntroduction to regression
Introduction to regression
 
DART
DARTDART
DART
 
Mycin
MycinMycin
Mycin
 
Expert systems
Expert systemsExpert systems
Expert systems
 
Dempster shafer theory
Dempster shafer theoryDempster shafer theory
Dempster shafer theory
 
Bayes network
Bayes networkBayes network
Bayes network
 
Bayes' theorem
Bayes' theoremBayes' theorem
Bayes' theorem
 
Knowledge based agents
Knowledge based agentsKnowledge based agents
Knowledge based agents
 
Rule based system
Rule based systemRule based system
Rule based system
 
Formal Logic in AI
Formal Logic in AIFormal Logic in AI
Formal Logic in AI
 
Production based system
Production based systemProduction based system
Production based system
 
Game playing in AI
Game playing in AIGame playing in AI
Game playing in AI
 
Diagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AIDiagnosis test of diabetics and hypertension by AI
Diagnosis test of diabetics and hypertension by AI
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 
A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”A study on “impact of artificial intelligence in covid19 diagnosis”
A study on “impact of artificial intelligence in covid19 diagnosis”
 

Recently uploaded

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPCeline George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomnelietumpap1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementmkooblal
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.arsicmarija21
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 

Recently uploaded (20)

Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
What is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERPWhat is Model Inheritance in Odoo 17 ERP
What is Model Inheritance in Odoo 17 ERP
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
ENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choomENGLISH6-Q4-W3.pptxqurter our high choom
ENGLISH6-Q4-W3.pptxqurter our high choom
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Raw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptxRaw materials used in Herbal Cosmetics.pptx
Raw materials used in Herbal Cosmetics.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Hierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of managementHierarchy of management that covers different levels of management
Hierarchy of management that covers different levels of management
 
AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.AmericanHighSchoolsprezentacijaoskolama.
AmericanHighSchoolsprezentacijaoskolama.
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 

SQL query Demo

  • 1. Department of Information Technology 1Data base Technologies (ITB4201) Introduction to Structured Query Language (SQL) Part 2 Dr. C.V. Suresh Babu Professor Department of IT Hindustan Institute of Science & Technology
  • 2. Department of Information Technology 2Data base Technologies (ITB4201) Action Plan • SQL Introduction • Simple Queries in SQL • Quiz
  • 3. Department of Information Technology 3Data base Technologies (ITB4201) Database queries • SELECT queries are used to extract information from a database: Example: SELECT first_name, last_name FROM president WHERE state = ‘NY’;
  • 4. Department of Information Technology 4Data base Technologies (ITB4201) More database queries • More examples SELECT first_name, last_name FROM president WHERE birth_date like ’19%’; SELECT count(*) FROM president WHERE state = ‘VT’; SELECT first_name, last_name FROM president WHERE state IN (ME,NH,VT,MA,CT,RI);
  • 5. Department of Information Technology 5Data base Technologies (ITB4201) How to create a DB table? • Use CREATE TABLE query, specifying fields and column types: Example: CREATE TABLE friends ( first_name varchar(25), last_name varchar(25), gender enum(‘M’, ‘F’), grade smallint unsigned, hair_color varchar(20), email varchar(30), screen_name varchar(25), phone char(12));
  • 6. Department of Information Technology 6Data base Technologies (ITB4201) Adding records to a table • Use the INSERT query: Example: INSERT INTO friends VALUES (‘Daffy’, ‘Duck’,‘M’,11,’Brunette’,‘daffy@disney.com’, YellowBill’, ’315-555-1213’);
  • 7. Department of Information Technology 7Data base Technologies (ITB4201) Editing records • Use the UPDATE query: Example: UPDATE friends SET phone=‘315-555-1234’ WHERE first_name=‘Daffy’ and last_name = ‘Duck’;
  • 8. Department of Information Technology 8Data base Technologies (ITB4201) Deleting records from a table • Use the DELETE query: Example: DELETE FROM friends WHERE first_name=‘Daffy’ and last_name=‘Duck’;
  • 9. Department of Information Technology 9Data base Technologies (ITB4201) How to use a DB table? • Finding a date: SELECT first_name, screen_name, phone FROM friends WHERE gender=‘F’ and grade > 10 and hair_color=‘Red’;
  • 10. Department of Information Technology 10Data base Technologies (ITB4201) Tutorial https://www.techonthenet.com/sql/select.php
  • 11. Department of Information Technology 11Data base Technologies (ITB4201) Quiz 1. Which of the following SQL clauses is used to DELETE tuples from a database table? a) DELETE b) REMOVE c) DROP d) CLEAR 2. Which of the following is not a DDL command? a) UPDATE b) TRUNCATE c) ALTER d) None of the Mentioned 3. The command to remove rows from a table ‘CUSTOMER’ is __________________ a) DROP FROM CUSTOMER b) UPDATE FROM CUSTOMER c) REMOVE FROM CUSTOMER d) DELETE FROM CUSTOMER WHERE 4. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”? a) SELECT * FROM Persons WHERE FirstName=’a’ b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’ c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’ d) SELECT * FROM Persons WHERE FirstName=’%a%’ 5. SQL query to find all the cities whose humidity is 95. a) SELECT city WHERE humidity = 95 b) SELECT city FROM weather WHERE humidity = 95 c) SELECT humidity = 89 FROM weather d) SELECT city FROM weather
  • 12. Department of Information Technology 12Data base Technologies (ITB4201) Quiz Answers 1. Which of the following SQL clauses is used to DELETE tuples from a database table? a) DELETE b) REMOVE c) DROP d) CLEAR 2. Which of the following is not a DDL command? a) UPDATE b) TRUNCATE c) ALTER d) None of the Mentioned 3. The command to remove rows from a table ‘CUSTOMER’ is __________________ a) DROP FROM CUSTOMER b) UPDATE FROM CUSTOMER c) REMOVE FROM CUSTOMER d) DELETE FROM CUSTOMER WHERE 4. With SQL, how do you select all the records from a table named “Persons” where the value of the column “FirstName” ends with an “a”? a) SELECT * FROM Persons WHERE FirstName=’a’ b) SELECT * FROM Persons WHERE FirstName LIKE ‘a%’ c) SELECT * FROM Persons WHERE FirstName LIKE ‘%a’ d) SELECT * FROM Persons WHERE FirstName=’%a%’ 5. SQL query to find all the cities whose humidity is 95. a) SELECT city WHERE humidity = 95 b) SELECT city FROM weather WHERE humidity = 95 c) SELECT humidity = 89 FROM weather d) SELECT city FROM weather