SlideShare a Scribd company logo
1 of 28
SQL COMMANDS
DATABASE SYSTEM
ANGELO T. RETITA
IT-INSTRUCTOR
OBJECTIVES
■ 1. To understand the usage of SQL SELECT Statement.
■ 2. To determine the syntax of SQL SELECT Statement.
■ 3. To understand the usage of SQL SELECT DISTINCT Statement.
■ 4. To determine the syntax of SQL SELECT DISTINCT Statement.
■ 5. To understand the usage of SQL WHERE Clause.
■ 6. To determine the syntax of SQL WHERE Clause.
SQL SELECT Statement
■ 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 Syntax
■ 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;
SELECT * Example
■ Example:
– 1. SELECT * FROM Customers;
Table Customers
SELECT Column Example
■ Example:
– 2. SELECT CustomerName, City FROM Customers;
Table Customers
SQL SELECT DISTINCT Statement
■ The SELECT DISTINCT statement is used to return only distinct (different) values.
■ Inside a table, a column often contains many duplicate values; and sometimes you
only want to list the different (distinct) values.
SELECT DISTINCT Syntax
■ SELECT DISTINCT column1, column2, ...
FROM table_name;
Example of SELECT DISTINCT
■ Below is a selection from the "Customers" table in the Northwind sample
database:
SELECT * FROM Customers;
Example 1.
■ A. The following SQL statement selects all (and duplicate) values from the
"Country" column in the "Customers" table:
■ B. The following SQL statement selects only the DISTINCT values from the
"Country" column in the "Customers" table:
A. SELECT Country FROM Customers; B. SELECT DISTINCT Country FROM Customers;
Example of SELECT DISTINCT Count
■ The following SQL statement lists the number of different (distinct) customer
countries:
SELECT Count(*) AS DistinctCountries
FROM (SELECT DISTINCT Country FROM Customers);
SELECT DISTINCT Country
FROM Customers;
SQL WHERE
Clause
SQL WHERE Clause
■ The WHERE clause is used to filter records.
■ The WHERE clause is used to extract only those records that fulfill a specified
condition.
WHERE Syntax
SELECT column1, column2, ...
FROM table_name
WHERE condition;
Note!
The WHERE clause is not only used in SELECT
statement, it is also used in UPDATE, DELETE
statement, etc.!
Demo Database
■ Below is a selection from the "Customers" table in the Northwind sample
database:
WHERE Clause Example
■ The following SQL statement selects all the customers from the country "Mexico",
in the "Customers" table:
SELECT * FROM Customers
WHERE Country='Mexico';
Text Fields vs. Numeric Fields
■ SQL requires single quotes around text values (most database systems will also
allow double quotes).
■ However, numeric fields should not be enclosed in quotes:
Example
SELECT * FROM Customers
WHERE CustomerID=1;
Operators in The WHERE Clause
Operator Description
= Equal
<> Not equal. Note: In some versions of SQL this operator may be written as !=
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
BETWEEN Between an inclusive range
LIKE Search for a pattern
IN To specify multiple possible values for a column
The following operators can be used in the WHERE clause:
=(Equal) Operator in The WHERE
Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerName = 'Alfreds Futterkiste');
Filtering records having CustomerName EQUAL Alfreds Futterkiste.
<>(Not Equal) Operator in The WHERE
Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerName <> 'Alfreds Futterkiste');
Filtering records of CustomerName NOT EQUAL Alfreds Futterkiste.
< (Less than) Operator in The WHERE
Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerID < 2);
Filtering records having CustomerID LESS THAN 2.
>(Greater than) Operator in The
WHERE Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode,
Country
FROM Customers
WHERE (CustomerID > 2)
Filtering records having CustomerID GREATER THAN 2.
<=(Less than equal) Operator in The
WHERE Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerID <= 2)
Filtering records having CustomerID LESS THAN EQAL 2.
>=(Greater than equal) Operator in The
WHERE Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerID >= 2)
Filtering records having CustomerID GREATER THAN EQUAL 2.
BETWEEN Operator in The WHERE
Clause Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerID BETWEEN 2 AND 4)
Filtering records of CustomerID BETWEEN 2 AND 4.
LIKE Operator in The WHERE Clause
Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerName LIKE 'an%')
Filtering records of CustomerName LIKE an.
IN Operator in The WHERE Clause
Example
SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country
FROM Customers
WHERE (CustomerID IN (1, 5))
Filtering records of CustomerID IN 1, 5.

More Related Content

What's hot

Lecture 4 sql {basics keys and constraints}
Lecture 4 sql {basics  keys and constraints}Lecture 4 sql {basics  keys and constraints}
Lecture 4 sql {basics keys and constraints}Shubham Shukla
 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan PasrichaMananPasricha
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in databaseHemant Suthar
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraintsuman kumar
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server iiIblesoft
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginnersISsoft
 
Report alephcollection code_call_no_order
Report alephcollection code_call_no_orderReport alephcollection code_call_no_order
Report alephcollection code_call_no_orderjanette_rozene
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinctBishal Ghimire
 
Database Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinDatabase Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinAl-Mamun Sarkar
 
Creating a vlookup v1.0 050813
Creating a vlookup v1.0 050813Creating a vlookup v1.0 050813
Creating a vlookup v1.0 050813Dave Shannon
 

What's hot (18)

Sql commands
Sql commandsSql commands
Sql commands
 
Lecture 4 sql {basics keys and constraints}
Lecture 4 sql {basics  keys and constraints}Lecture 4 sql {basics  keys and constraints}
Lecture 4 sql {basics keys and constraints}
 
Sql clauses by Manan Pasricha
Sql clauses by Manan PasrichaSql clauses by Manan Pasricha
Sql clauses by Manan Pasricha
 
Null values, insert, delete and update in database
Null values, insert, delete and update in databaseNull values, insert, delete and update in database
Null values, insert, delete and update in database
 
Vlookup In Excel
Vlookup In ExcelVlookup In Excel
Vlookup In Excel
 
Entigrity constraint
Entigrity constraintEntigrity constraint
Entigrity constraint
 
Sql cheat sheet
Sql cheat sheetSql cheat sheet
Sql cheat sheet
 
Query
QueryQuery
Query
 
Ms sql server ii
Ms sql server  iiMs sql server  ii
Ms sql server ii
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
Report alephcollection code_call_no_order
Report alephcollection code_call_no_orderReport alephcollection code_call_no_order
Report alephcollection code_call_no_order
 
Les06
Les06Les06
Les06
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
Database Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, JoinDatabase Management - Lecture 3 - SQL Aggregate Functions, Join
Database Management - Lecture 3 - SQL Aggregate Functions, Join
 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
 
SQL Core Concept
SQL Core ConceptSQL Core Concept
SQL Core Concept
 
Les05
Les05Les05
Les05
 
Creating a vlookup v1.0 050813
Creating a vlookup v1.0 050813Creating a vlookup v1.0 050813
Creating a vlookup v1.0 050813
 

Similar to SQL COMMANDS DATABASE SYSTEM

ADV Powepoint 2 Lec.pptx
ADV Powepoint 2 Lec.pptxADV Powepoint 2 Lec.pptx
ADV Powepoint 2 Lec.pptxArjayBalberan1
 
SQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdfSQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdfAnishurRehman1
 
SQL Assessment Command Statements
SQL Assessment Command StatementsSQL Assessment Command Statements
SQL Assessment Command StatementsShaun Wilson
 
ADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptxADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptxArjayBalberan1
 
Data Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdfData Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdfhowto4ucontact
 
ADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptxADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptxArjayBalberan1
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sqlN.Jagadish Kumar
 
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptxUnit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptxHAMEEDHUSSAINBU21CSE
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commandsBelle Wx
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index TuningManikanda kumar
 
Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);abdul talha
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1Swapnali Pawar
 
SQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfSQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfMadhusha15
 
Practical guide to SQL basics
Practical guide to SQL basicsPractical guide to SQL basics
Practical guide to SQL basicsPavani Ganti
 

Similar to SQL COMMANDS DATABASE SYSTEM (20)

ADV Powepoint 2 Lec.pptx
ADV Powepoint 2 Lec.pptxADV Powepoint 2 Lec.pptx
ADV Powepoint 2 Lec.pptx
 
SQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdfSQL Beginners anishurrehman.cloud.pdf
SQL Beginners anishurrehman.cloud.pdf
 
SQL Assessment Command Statements
SQL Assessment Command StatementsSQL Assessment Command Statements
SQL Assessment Command Statements
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
ADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptxADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptx
 
Data Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdfData Base Management System Lecture 10.pdf
Data Base Management System Lecture 10.pdf
 
ADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptxADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptx
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptxUnit 3-Select Options and Aggregate Functions in SQL (1).pptx
Unit 3-Select Options and Aggregate Functions in SQL (1).pptx
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
MySQL Query And Index Tuning
MySQL Query And Index TuningMySQL Query And Index Tuning
MySQL Query And Index Tuning
 
ADV PPT 8 LAB.pptx
ADV PPT 8 LAB.pptxADV PPT 8 LAB.pptx
ADV PPT 8 LAB.pptx
 
SQL
SQLSQL
SQL
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);Farheen abdul hameed ip project (MY SQL);
Farheen abdul hameed ip project (MY SQL);
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
SQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfSQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdf
 
Practical guide to SQL basics
Practical guide to SQL basicsPractical guide to SQL basics
Practical guide to SQL basics
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 

More from MLG College of Learning, Inc (20)

PC111.Lesson2
PC111.Lesson2PC111.Lesson2
PC111.Lesson2
 
PC111.Lesson1
PC111.Lesson1PC111.Lesson1
PC111.Lesson1
 
PC111-lesson1.pptx
PC111-lesson1.pptxPC111-lesson1.pptx
PC111-lesson1.pptx
 
PC LEESOON 6.pptx
PC LEESOON 6.pptxPC LEESOON 6.pptx
PC LEESOON 6.pptx
 
PC 106 PPT-09.pptx
PC 106 PPT-09.pptxPC 106 PPT-09.pptx
PC 106 PPT-09.pptx
 
PC 106 PPT-07
PC 106 PPT-07PC 106 PPT-07
PC 106 PPT-07
 
PC 106 PPT-01
PC 106 PPT-01PC 106 PPT-01
PC 106 PPT-01
 
PC 106 PPT-06
PC 106 PPT-06PC 106 PPT-06
PC 106 PPT-06
 
PC 106 PPT-05
PC 106 PPT-05PC 106 PPT-05
PC 106 PPT-05
 
PC 106 Slide 04
PC 106 Slide 04PC 106 Slide 04
PC 106 Slide 04
 
PC 106 Slide no.02
PC 106 Slide no.02PC 106 Slide no.02
PC 106 Slide no.02
 
pc-106-slide-3
pc-106-slide-3pc-106-slide-3
pc-106-slide-3
 
PC 106 Slide 2
PC 106 Slide 2PC 106 Slide 2
PC 106 Slide 2
 
PC 106 Slide 1.pptx
PC 106 Slide 1.pptxPC 106 Slide 1.pptx
PC 106 Slide 1.pptx
 
Db2 characteristics of db ms
Db2 characteristics of db msDb2 characteristics of db ms
Db2 characteristics of db ms
 
Db1 introduction
Db1 introductionDb1 introduction
Db1 introduction
 
Lesson 3.2
Lesson 3.2Lesson 3.2
Lesson 3.2
 
Lesson 3.1
Lesson 3.1Lesson 3.1
Lesson 3.1
 
Lesson 1.6
Lesson 1.6Lesson 1.6
Lesson 1.6
 
Lesson 3.2
Lesson 3.2Lesson 3.2
Lesson 3.2
 

Recently uploaded

software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 

Recently uploaded (20)

software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 

SQL COMMANDS DATABASE SYSTEM

  • 1. SQL COMMANDS DATABASE SYSTEM ANGELO T. RETITA IT-INSTRUCTOR
  • 2. OBJECTIVES ■ 1. To understand the usage of SQL SELECT Statement. ■ 2. To determine the syntax of SQL SELECT Statement. ■ 3. To understand the usage of SQL SELECT DISTINCT Statement. ■ 4. To determine the syntax of SQL SELECT DISTINCT Statement. ■ 5. To understand the usage of SQL WHERE Clause. ■ 6. To determine the syntax of SQL WHERE Clause.
  • 3. SQL SELECT Statement ■ The SELECT statement is used to select data from a database. ■ The data returned is stored in a result table, called the ■RESULT-SET
  • 4. SELECT Syntax ■ 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;
  • 5. SELECT * Example ■ Example: – 1. SELECT * FROM Customers; Table Customers
  • 6. SELECT Column Example ■ Example: – 2. SELECT CustomerName, City FROM Customers; Table Customers
  • 7. SQL SELECT DISTINCT Statement ■ The SELECT DISTINCT statement is used to return only distinct (different) values. ■ Inside a table, a column often contains many duplicate values; and sometimes you only want to list the different (distinct) values.
  • 8. SELECT DISTINCT Syntax ■ SELECT DISTINCT column1, column2, ... FROM table_name;
  • 9. Example of SELECT DISTINCT ■ Below is a selection from the "Customers" table in the Northwind sample database: SELECT * FROM Customers;
  • 10. Example 1. ■ A. The following SQL statement selects all (and duplicate) values from the "Country" column in the "Customers" table: ■ B. The following SQL statement selects only the DISTINCT values from the "Country" column in the "Customers" table: A. SELECT Country FROM Customers; B. SELECT DISTINCT Country FROM Customers;
  • 11. Example of SELECT DISTINCT Count ■ The following SQL statement lists the number of different (distinct) customer countries: SELECT Count(*) AS DistinctCountries FROM (SELECT DISTINCT Country FROM Customers); SELECT DISTINCT Country FROM Customers;
  • 13. SQL WHERE Clause ■ The WHERE clause is used to filter records. ■ The WHERE clause is used to extract only those records that fulfill a specified condition.
  • 14. WHERE Syntax SELECT column1, column2, ... FROM table_name WHERE condition;
  • 15. Note! The WHERE clause is not only used in SELECT statement, it is also used in UPDATE, DELETE statement, etc.!
  • 16. Demo Database ■ Below is a selection from the "Customers" table in the Northwind sample database:
  • 17. WHERE Clause Example ■ The following SQL statement selects all the customers from the country "Mexico", in the "Customers" table: SELECT * FROM Customers WHERE Country='Mexico';
  • 18. Text Fields vs. Numeric Fields ■ SQL requires single quotes around text values (most database systems will also allow double quotes). ■ However, numeric fields should not be enclosed in quotes: Example SELECT * FROM Customers WHERE CustomerID=1;
  • 19. Operators in The WHERE Clause Operator Description = Equal <> Not equal. Note: In some versions of SQL this operator may be written as != > Greater than < Less than >= Greater than or equal <= Less than or equal BETWEEN Between an inclusive range LIKE Search for a pattern IN To specify multiple possible values for a column The following operators can be used in the WHERE clause:
  • 20. =(Equal) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerName = 'Alfreds Futterkiste'); Filtering records having CustomerName EQUAL Alfreds Futterkiste.
  • 21. <>(Not Equal) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerName <> 'Alfreds Futterkiste'); Filtering records of CustomerName NOT EQUAL Alfreds Futterkiste.
  • 22. < (Less than) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID < 2); Filtering records having CustomerID LESS THAN 2.
  • 23. >(Greater than) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID > 2) Filtering records having CustomerID GREATER THAN 2.
  • 24. <=(Less than equal) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID <= 2) Filtering records having CustomerID LESS THAN EQAL 2.
  • 25. >=(Greater than equal) Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID >= 2) Filtering records having CustomerID GREATER THAN EQUAL 2.
  • 26. BETWEEN Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID BETWEEN 2 AND 4) Filtering records of CustomerID BETWEEN 2 AND 4.
  • 27. LIKE Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerName LIKE 'an%') Filtering records of CustomerName LIKE an.
  • 28. IN Operator in The WHERE Clause Example SELECT CustomerID, CustomerName, ContactName, Address, City, PostalCode, Country FROM Customers WHERE (CustomerID IN (1, 5)) Filtering records of CustomerID IN 1, 5.