SlideShare a Scribd company logo
1
2
Name ID 
1. Setu haque 
3
The Commands That Are Going To Be Discussed 
1.SELECT 
2.SELECT DISTINCT 
3.WHERE 
4.ORDER BY 
5.AND 
6.OR 
4
SELECT 
Function of SELECT 
The SELECT statement is used to select data from a database. 
The SQL SELECT Statement 
The SELECT statement is used to select data from a database. 
The result is stored in a result table, called the result-set. 
SQL SELECT Syntax 
SELECT ColumnName,ColumnName FROM TableName; 
and 
SELECT * FROM TableName; 
5
SELECT 
Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
SELECT 
??????????????????
SELECT 
SELECT Column Example 
The following SQL statement selects the “StudentId" columns from the “Students" 
table: 
The Practical Output
SELECT 
SELECT Column Example 
The following SQL statement selects the “StudentId“ and “StudentName” 
columns from the “Students" table: 
The Practical Output
SELECT 
SELECT Column Example 
The following SQL statement selects the all columns by using *(staric sign) from 
the “Students" table: 
The Practical Output
SELECT 
DISTINCT 
Function of SELECT DISTINCT 
The SELECT DISTINCT statement is used to return only distinct (different) values. 
The SQL SELECT DISTINCT Statement 
In a table, a column may contain many duplicate values; and sometimes you only 
want to list the different (distinct) values. 
The DISTINCT keyword can be used to return only distinct (different) values. 
SQL SELECT DISTINCT Syntax 
SELECT DISTINCT ColumnName,ColumnName FROM TableName;
SELECT 
DISTINCT Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
SELECT 
DISTINCT 
SELECT DISTINCT Column Example 
The following SQL statement selects the “CourseNo" columns from the “Students" 
table: 
The Practical Output
SELECT 
DISTINCT 
SELECT DISTINCT Column Example 
The following SQL statement selects the “StudentId“ and “CourseNo” columns 
from the “Students" table: 
The Practical Output
WHERE 
Function of WHERE 
The WHERE clause is used to filter records. 
The SQL WHERE Clause 
The WHERE clause is used to extract only those records that fulfill a specified 
criterion. 
SQL WHERE Syntax 
SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName 
operator value;
WHERE 
Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
WHERE 
WHERE Column Example 
The following SQL statement selects the “Section" columns from the CourseNo 
“CSC434", in the “Students" table: 
The Practical Output
WHERE 
WHERE Column Example 
The following SQL statement selects all the students from the CourseNo 
“CSC434", in the “Students" table: 
The Practical Output
WHERE 
Operators in The WHERE Clause 
The following operators can be used 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
ORDER BY 
Function of ORDER BY DISTINCT 
The ORDER BY keyword is used to sort the result-set. 
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 records in ascending order by default. To sort 
the records in a descending order, DESC keyword is used. 
SQL ORDER BY Syntax 
SELECT ColumnName,ColumnName FROM TableName ORDER BY 
ColumnName,ColumnName ASC|DESC; [Here, ASC=Ascending & 
DESC=Descending]
ORDER 
BY Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
ORDER BY 
ORDER BY Column Example 
The following SQL statement selects the "CourseNo" from the “Students" table, 
sorted by the “StudentId" column: 
The Practical Output
ORDER BY 
ORDER BY Column Example 
The following SQL statement selects the "CourseNo" from the “Students" table, 
sorted by the “StudentId" column in descending form: 
The Practical Output
ORDER BY 
ORDER BY Column Example 
The following SQL statement selects all students from the “Students" table, sorted 
by the “StudentId" column: 
The Practical Output
ORDER BY 
ORDER BY Column Example 
The following SQL statement selects all students from the “Students" table, sorted 
by the “StudentId" column in descending form: 
The Practical Output
AND Operator 
Function of AND Operators 
The AND operators are used to filter records based on more than one condition. 
The SQL AND Operators 
The AND operator displays a record if both the first condition AND the second 
condition are true. 
SQL AND Syntax 
SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName 
operator value AND ColumnName operator value;
AND Operator 
Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
AND Operator 
AND Operator Column Example 
The following SQL statement selects the “StudentId” from the Section “D" AND the 
CourseNo “CSC434", in the “Students" table: 
The Practical Output
AND Operator 
AND Operator Column Example 
The following SQL statement selects all students from the Section “D" AND the 
CourseNo “CSC434", in the “Students" table: 
The Practical Output
OR Operator 
Function of OR Operators 
The OR operators are used to filter records based on more than one condition. 
The SQL OR Operators 
The OR operator displays a record if either the first condition OR the second 
condition is true. 
SQL OR Syntax 
SELECT ColumnName,ColumnName FROM TableName WHERE 
ColumnName operator value OR ColumnName operator value;
OR Operator 
Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
OR Operator 
OR Operator Column Example 
The following SQL statement selects the “StudentName” and “Section” coloumns 
from the StudentId “13103013" OR the CourseNo “CSC434", in the “Students" 
taTbhlee :Practical Output
OR Operator 
OR Column Example 
The following SQL statement selects all students from the StudentId “13103013" 
OR the CourseNo “CSC434", in the “Students" table : 
The Practical Output
Combination of AND & OR Operators 
Combining AND & OR Operators 
We can also combine AND and OR (use parenthesis to form complex 
expressions). 
SQL Combination AND & OR Operators Syntax 
SELECT ColumnName,ColumnName FROM TableName WHERE 
ColumnName operator value AND (ColumnName operator value OR 
ColumnName operator value);
Combination of AND & OR Operators 
Demo Database 
StudentId StudentName Course Section 
13103007 Bithi Akter CSC433 D 
13103010 Sanjida Tasnim CSC434 E 
13103013 Shohana Akter CSC434 D
Combination of AND & OR Operators 
Combination AND & OR Operators Column Example 
The following SQL statement selects all students from the CourseNo “CSC434" 
AND the StudentId must be equal to “13103013" OR the Section must be equal to 
“E", in the “Students" table: 
The Practical Output
Any 
Question?
Dbms presentationnnnn

More Related Content

Similar to Dbms presentationnnnn

Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
Edureka!
 
Oracle Notes
Oracle NotesOracle Notes
Oracle Notes
Abhishek Sharma
 
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
HAMEEDHUSSAINBU21CSE
 
Database_Systems_Lab_5_Presentation.pptx
Database_Systems_Lab_5_Presentation.pptxDatabase_Systems_Lab_5_Presentation.pptx
Database_Systems_Lab_5_Presentation.pptx
khaqan2
 
Structured Query Language (SQL) Part 2.pptx
Structured Query Language (SQL) Part 2.pptxStructured Query Language (SQL) Part 2.pptx
Structured Query Language (SQL) Part 2.pptx
EllenGracePorras
 
Sql intro
Sql introSql intro
Sql introglubox
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
newrforce
 
UNIT 2 Structured query language commands
UNIT 2 Structured query language commandsUNIT 2 Structured query language commands
UNIT 2 Structured query language commands
Bhakti Pawar
 
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
howto4ucontact
 
Lab
LabLab
SQL Keywords and Functions.pptx
SQL Keywords and Functions.pptxSQL Keywords and Functions.pptx
SQL Keywords and Functions.pptx
RUBAB79
 
mysql.ppt
mysql.pptmysql.ppt
mysql.ppt
nawaz65
 
Advanced Database Systems - Presentation 3.pptx
Advanced Database Systems - Presentation 3.pptxAdvanced Database Systems - Presentation 3.pptx
Advanced Database Systems - Presentation 3.pptx
EllenGracePorras
 
Database queries
Database queriesDatabase queries
Database queries
laiba29012
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
SuhaniSinha9
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
IMsKanchanaI
 
Les01
Les01Les01

Similar to Dbms presentationnnnn (20)

Sql Basics | Edureka
Sql Basics | EdurekaSql Basics | Edureka
Sql Basics | Edureka
 
01 basic orders
01   basic orders01   basic orders
01 basic orders
 
Oracle Notes
Oracle NotesOracle Notes
Oracle Notes
 
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
 
PPT
PPTPPT
PPT
 
Database_Systems_Lab_5_Presentation.pptx
Database_Systems_Lab_5_Presentation.pptxDatabase_Systems_Lab_5_Presentation.pptx
Database_Systems_Lab_5_Presentation.pptx
 
Structured Query Language (SQL) Part 2.pptx
Structured Query Language (SQL) Part 2.pptxStructured Query Language (SQL) Part 2.pptx
Structured Query Language (SQL) Part 2.pptx
 
Sql intro
Sql introSql intro
Sql intro
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
Query
QueryQuery
Query
 
UNIT 2 Structured query language commands
UNIT 2 Structured query language commandsUNIT 2 Structured query language commands
UNIT 2 Structured query language commands
 
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
 
Lab
LabLab
Lab
 
SQL Keywords and Functions.pptx
SQL Keywords and Functions.pptxSQL Keywords and Functions.pptx
SQL Keywords and Functions.pptx
 
mysql.ppt
mysql.pptmysql.ppt
mysql.ppt
 
Advanced Database Systems - Presentation 3.pptx
Advanced Database Systems - Presentation 3.pptxAdvanced Database Systems - Presentation 3.pptx
Advanced Database Systems - Presentation 3.pptx
 
Database queries
Database queriesDatabase queries
Database queries
 
DBMS LAB M.docx
DBMS LAB M.docxDBMS LAB M.docx
DBMS LAB M.docx
 
Its about a sql topic for basic structured query language
Its about a sql topic for basic structured query languageIts about a sql topic for basic structured query language
Its about a sql topic for basic structured query language
 
Les01
Les01Les01
Les01
 

More from sumi haque

Concept of Computer
Concept of ComputerConcept of Computer
Concept of Computer
sumi haque
 
Final dfa
Final dfaFinal dfa
Final dfa
sumi haque
 
Client billing System for ISP
Client billing System for ISPClient billing System for ISP
Client billing System for ISP
sumi haque
 
Air pollution presentation.ppt
Air pollution presentation.pptAir pollution presentation.ppt
Air pollution presentation.ppt
sumi haque
 
Dbms presentation of Automatic Car parking System
Dbms presentation of Automatic Car parking SystemDbms presentation of Automatic Car parking System
Dbms presentation of Automatic Car parking System
sumi haque
 
Tourism in-bangladesh ppt
Tourism in-bangladesh pptTourism in-bangladesh ppt
Tourism in-bangladesh ppt
sumi haque
 

More from sumi haque (6)

Concept of Computer
Concept of ComputerConcept of Computer
Concept of Computer
 
Final dfa
Final dfaFinal dfa
Final dfa
 
Client billing System for ISP
Client billing System for ISPClient billing System for ISP
Client billing System for ISP
 
Air pollution presentation.ppt
Air pollution presentation.pptAir pollution presentation.ppt
Air pollution presentation.ppt
 
Dbms presentation of Automatic Car parking System
Dbms presentation of Automatic Car parking SystemDbms presentation of Automatic Car parking System
Dbms presentation of Automatic Car parking System
 
Tourism in-bangladesh ppt
Tourism in-bangladesh pptTourism in-bangladesh ppt
Tourism in-bangladesh ppt
 

Recently uploaded

一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
ydteq
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
Vijay Dialani, PhD
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
ongomchris
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 

Recently uploaded (20)

一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
一比一原版(UofT毕业证)多伦多大学毕业证成绩单如何办理
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
ML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptxML for identifying fraud using open blockchain data.pptx
ML for identifying fraud using open blockchain data.pptx
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
space technology lecture notes on satellite
space technology lecture notes on satellitespace technology lecture notes on satellite
space technology lecture notes on satellite
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 

Dbms presentationnnnn

  • 1. 1
  • 2. 2
  • 3. Name ID 1. Setu haque 3
  • 4. The Commands That Are Going To Be Discussed 1.SELECT 2.SELECT DISTINCT 3.WHERE 4.ORDER BY 5.AND 6.OR 4
  • 5. SELECT Function of SELECT The SELECT statement is used to select data from a database. The SQL SELECT Statement The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. SQL SELECT Syntax SELECT ColumnName,ColumnName FROM TableName; and SELECT * FROM TableName; 5
  • 6. SELECT Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 8. SELECT SELECT Column Example The following SQL statement selects the “StudentId" columns from the “Students" table: The Practical Output
  • 9. SELECT SELECT Column Example The following SQL statement selects the “StudentId“ and “StudentName” columns from the “Students" table: The Practical Output
  • 10. SELECT SELECT Column Example The following SQL statement selects the all columns by using *(staric sign) from the “Students" table: The Practical Output
  • 11. SELECT DISTINCT Function of SELECT DISTINCT The SELECT DISTINCT statement is used to return only distinct (different) values. The SQL SELECT DISTINCT Statement In a table, a column may contain many duplicate values; and sometimes you only want to list the different (distinct) values. The DISTINCT keyword can be used to return only distinct (different) values. SQL SELECT DISTINCT Syntax SELECT DISTINCT ColumnName,ColumnName FROM TableName;
  • 12. SELECT DISTINCT Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 13. SELECT DISTINCT SELECT DISTINCT Column Example The following SQL statement selects the “CourseNo" columns from the “Students" table: The Practical Output
  • 14. SELECT DISTINCT SELECT DISTINCT Column Example The following SQL statement selects the “StudentId“ and “CourseNo” columns from the “Students" table: The Practical Output
  • 15. WHERE Function of WHERE The WHERE clause is used to filter records. The SQL WHERE Clause The WHERE clause is used to extract only those records that fulfill a specified criterion. SQL WHERE Syntax SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName operator value;
  • 16. WHERE Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 17. WHERE WHERE Column Example The following SQL statement selects the “Section" columns from the CourseNo “CSC434", in the “Students" table: The Practical Output
  • 18. WHERE WHERE Column Example The following SQL statement selects all the students from the CourseNo “CSC434", in the “Students" table: The Practical Output
  • 19. WHERE Operators in The WHERE Clause The following operators can be used 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
  • 20. ORDER BY Function of ORDER BY DISTINCT The ORDER BY keyword is used to sort the result-set. 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 records in ascending order by default. To sort the records in a descending order, DESC keyword is used. SQL ORDER BY Syntax SELECT ColumnName,ColumnName FROM TableName ORDER BY ColumnName,ColumnName ASC|DESC; [Here, ASC=Ascending & DESC=Descending]
  • 21. ORDER BY Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 22. ORDER BY ORDER BY Column Example The following SQL statement selects the "CourseNo" from the “Students" table, sorted by the “StudentId" column: The Practical Output
  • 23. ORDER BY ORDER BY Column Example The following SQL statement selects the "CourseNo" from the “Students" table, sorted by the “StudentId" column in descending form: The Practical Output
  • 24. ORDER BY ORDER BY Column Example The following SQL statement selects all students from the “Students" table, sorted by the “StudentId" column: The Practical Output
  • 25. ORDER BY ORDER BY Column Example The following SQL statement selects all students from the “Students" table, sorted by the “StudentId" column in descending form: The Practical Output
  • 26. AND Operator Function of AND Operators The AND operators are used to filter records based on more than one condition. The SQL AND Operators The AND operator displays a record if both the first condition AND the second condition are true. SQL AND Syntax SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName operator value AND ColumnName operator value;
  • 27. AND Operator Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 28. AND Operator AND Operator Column Example The following SQL statement selects the “StudentId” from the Section “D" AND the CourseNo “CSC434", in the “Students" table: The Practical Output
  • 29. AND Operator AND Operator Column Example The following SQL statement selects all students from the Section “D" AND the CourseNo “CSC434", in the “Students" table: The Practical Output
  • 30. OR Operator Function of OR Operators The OR operators are used to filter records based on more than one condition. The SQL OR Operators The OR operator displays a record if either the first condition OR the second condition is true. SQL OR Syntax SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName operator value OR ColumnName operator value;
  • 31. OR Operator Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 32. OR Operator OR Operator Column Example The following SQL statement selects the “StudentName” and “Section” coloumns from the StudentId “13103013" OR the CourseNo “CSC434", in the “Students" taTbhlee :Practical Output
  • 33. OR Operator OR Column Example The following SQL statement selects all students from the StudentId “13103013" OR the CourseNo “CSC434", in the “Students" table : The Practical Output
  • 34. Combination of AND & OR Operators Combining AND & OR Operators We can also combine AND and OR (use parenthesis to form complex expressions). SQL Combination AND & OR Operators Syntax SELECT ColumnName,ColumnName FROM TableName WHERE ColumnName operator value AND (ColumnName operator value OR ColumnName operator value);
  • 35. Combination of AND & OR Operators Demo Database StudentId StudentName Course Section 13103007 Bithi Akter CSC433 D 13103010 Sanjida Tasnim CSC434 E 13103013 Shohana Akter CSC434 D
  • 36. Combination of AND & OR Operators Combination AND & OR Operators Column Example The following SQL statement selects all students from the CourseNo “CSC434" AND the StudentId must be equal to “13103013" OR the Section must be equal to “E", in the “Students" table: The Practical Output