SlideShare a Scribd company logo
1 of 2
Download to read offline
8/10/13 SQL WHERE Clause
beginner-sql-tutorial.com/sql-where-clause.htm 1/2
SQL WHERE Clause
The WHERE Clause is used when you want to retrieve specific information from a table excluding other irrelevant
data. For example, when you want to see the information about students in class 10th only then you do need the
information about the students in other class. Retrieving information about all the students would increase the
processing time for the query.
So SQL offers a feature called WHERE clause, which we can use to restrict the data that is retrieved. The
condition you provide in the WHERE clause filters the rows retrieved from the table and gives you only those
rows which you expected to see. WHERE clause can be used along with SELECT, DELETE, UPDATE statements.
Syntax of SQL WHERE Clause:
WHERE {column or expression} comparison-operator value
Syntax for a WHERE clause with Select statement is:
SELECT column_list FROM table-name
WHERE condition;
column or expression - Is the column of a table or a expression
comparison-operator - operators like = < > etc.
value - Any user value or a column name for comparison
For Example: To find the name of a student with id 100, the query would be like:
SELECT first_name, last_name FROM student_details
WHERE id = 100;
Comparison Operators and Logical Operators are used in WHERE Clause. These operators are discussed in the
next chapter.
NOTE: Aliases defined for the columns in the SELECT statement cannot be used in the WHERE clause to set
8/10/13 SQL WHERE Clause
beginner-sql-tutorial.com/sql-where-clause.htm 2/2
conditions. Only aliases created for tables can be used to reference the columns in the table.
How to use expressions in the WHERE Clause?
Expressions can also be used in the WHERE clause of the SELECT statement.
For example: Lets consider the employee table. If you want to display employee name, current salary, and a
20% increase in the salary for only those products where the percentage increase in salary is greater than
30000, the SELECT statement can be written as shown below
SELECT name, salary, salary*1.2 AS new_salary FROM employee
WHERE salary*1.2 > 30000;
Output:
name salarynew_salary
--------
---
-------
---
--------------
--
Hrithik 35000 37000
Harsha 35000 37000
Priya 30000 360000
NOTE: Aliases defined in the SELECT Statement can be used in WHERE Clause.

More Related Content

What's hot

Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteAl-Mamun Sarkar
ย 
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
ย 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNIONJamshid Hashimi
ย 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Achmad Solichin
ย 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSgaurav koriya
ย 
Union based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointUnion based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointAl Zarqali
ย 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3Gurpreet singh
ย 
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
ย 
1 introduction to my sql
1 introduction to my sql1 introduction to my sql
1 introduction to my sqlProf. Erwin Globio
ย 
Sql basics
Sql  basicsSql  basics
Sql basicsGenesis Omo
ย 
retrieving data using SQL statements
retrieving data using SQL statementsretrieving data using SQL statements
retrieving data using SQL statementsArun Nair
ย 

What's hot (14)

Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
ย 
View
ViewView
View
ย 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
ย 
Sql basics v2
Sql basics v2Sql basics v2
Sql basics v2
ย 
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
ย 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
ย 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)
ย 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
ย 
Union based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials PointUnion based sql injection by Urdu Tutorials Point
Union based sql injection by Urdu Tutorials Point
ย 
Oracle SQL Part 3
Oracle SQL Part 3Oracle SQL Part 3
Oracle SQL Part 3
ย 
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)
ย 
1 introduction to my sql
1 introduction to my sql1 introduction to my sql
1 introduction to my sql
ย 
Sql basics
Sql  basicsSql  basics
Sql basics
ย 
retrieving data using SQL statements
retrieving data using SQL statementsretrieving data using SQL statements
retrieving data using SQL statements
ย 

Viewers also liked

Social media and the entertainment industry
Social media and the entertainment industrySocial media and the entertainment industry
Social media and the entertainment industryalecdiaz99
ย 
15 job-search-tips-that-work
15 job-search-tips-that-work15 job-search-tips-that-work
15 job-search-tips-that-workgetajobnow
ย 
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997Muthuselvam RS
ย 
Greensolutions presentations10 june 2012
Greensolutions presentations10 june 2012Greensolutions presentations10 june 2012
Greensolutions presentations10 june 2012farm2fuel
ย 
Amendment to ssr 2010 part II
Amendment to ssr 2010 part IIAmendment to ssr 2010 part II
Amendment to ssr 2010 part IIswaparnika
ย 
Personal swiss 2012_recrutingtrends_final
Personal swiss 2012_recrutingtrends_finalPersonal swiss 2012_recrutingtrends_final
Personal swiss 2012_recrutingtrends_finalMichel Ganouchi
ย 

Viewers also liked (7)

1 b class 1
1 b class 11 b class 1
1 b class 1
ย 
Social media and the entertainment industry
Social media and the entertainment industrySocial media and the entertainment industry
Social media and the entertainment industry
ย 
15 job-search-tips-that-work
15 job-search-tips-that-work15 job-search-tips-that-work
15 job-search-tips-that-work
ย 
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997UpsilonPiEpsilon-UniversityOfBridgeport-May1997
UpsilonPiEpsilon-UniversityOfBridgeport-May1997
ย 
Greensolutions presentations10 june 2012
Greensolutions presentations10 june 2012Greensolutions presentations10 june 2012
Greensolutions presentations10 june 2012
ย 
Amendment to ssr 2010 part II
Amendment to ssr 2010 part IIAmendment to ssr 2010 part II
Amendment to ssr 2010 part II
ย 
Personal swiss 2012_recrutingtrends_final
Personal swiss 2012_recrutingtrends_finalPersonal swiss 2012_recrutingtrends_final
Personal swiss 2012_recrutingtrends_final
ย 

Similar to Sql where clause

Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4Dr. C.V. Suresh Babu
ย 
Chinabankppt
ChinabankpptChinabankppt
Chinabankpptnewrforce
ย 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQueryAbhishek590097
ย 
SQL Query
SQL QuerySQL Query
SQL QueryImam340267
ย 
Merging data (1)
Merging data (1)Merging data (1)
Merging data (1)Ris Fernandez
ย 
Sql joins
Sql joinsSql joins
Sql joinsVivek Singh
ย 
Sql having clause
Sql having clauseSql having clause
Sql having clauseVivek Singh
ย 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESVENNILAV6
ย 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql materialprathap kumar
ย 
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 languageIMsKanchanaI
ย 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joinsoracle content
ย 
sql statement
sql statementsql statement
sql statementzx25 zx25
ย 

Similar to Sql where clause (20)

Les18
Les18Les18
Les18
ย 
Sql2
Sql2Sql2
Sql2
ย 
Les06
Les06Les06
Les06
ย 
Query
QueryQuery
Query
ย 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
ย 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
ย 
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQueryPPT  of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
PPT of Common Table Expression (CTE), Window Functions, JOINS, SubQuery
ย 
SQL Query
SQL QuerySQL Query
SQL Query
ย 
Merging data (1)
Merging data (1)Merging data (1)
Merging data (1)
ย 
Sql joins
Sql joinsSql joins
Sql joins
ย 
UNIT-3.pptx
UNIT-3.pptxUNIT-3.pptx
UNIT-3.pptx
ย 
Sql having clause
Sql having clauseSql having clause
Sql having clause
ย 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
ย 
Sql (DBMS)
Sql (DBMS)Sql (DBMS)
Sql (DBMS)
ย 
Oracle sql material
Oracle sql materialOracle sql material
Oracle sql material
ย 
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
ย 
0808.pdf
0808.pdf0808.pdf
0808.pdf
ย 
0808.pdf
0808.pdf0808.pdf
0808.pdf
ย 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
ย 
sql statement
sql statementsql statement
sql statement
ย 

More from Vivek Singh

C programming session 14
C programming session 14C programming session 14
C programming session 14Vivek Singh
ย 
C programming session 13
C programming session 13C programming session 13
C programming session 13Vivek Singh
ย 
C programming session 11
C programming session 11C programming session 11
C programming session 11Vivek Singh
ย 
C programming session 10
C programming session 10C programming session 10
C programming session 10Vivek Singh
ย 
C programming session 08
C programming session 08C programming session 08
C programming session 08Vivek Singh
ย 
C programming session 07
C programming session 07C programming session 07
C programming session 07Vivek Singh
ย 
C programming session 05
C programming session 05C programming session 05
C programming session 05Vivek Singh
ย 
C programming session 04
C programming session 04C programming session 04
C programming session 04Vivek Singh
ย 
C programming session 02
C programming session 02C programming session 02
C programming session 02Vivek Singh
ย 
C programming session 01
C programming session 01C programming session 01
C programming session 01Vivek Singh
ย 
C programming session 16
C programming session 16C programming session 16
C programming session 16Vivek Singh
ย 
Niit aptitude question paper
Niit aptitude question paperNiit aptitude question paper
Niit aptitude question paperVivek Singh
ย 
Excel shortcut and tips
Excel shortcut and tipsExcel shortcut and tips
Excel shortcut and tipsVivek Singh
ย 
Sql where clause
Sql where clauseSql where clause
Sql where clauseVivek Singh
ย 
Sql update statement
Sql update statementSql update statement
Sql update statementVivek Singh
ย 
Sql tutorial, tutorials sql
Sql tutorial, tutorials sqlSql tutorial, tutorials sql
Sql tutorial, tutorials sqlVivek Singh
ย 
Sql subquery
Sql subquerySql subquery
Sql subqueryVivek Singh
ย 
Sql rename
Sql renameSql rename
Sql renameVivek Singh
ย 
Sql query tuning or query optimization
Sql query tuning or query optimizationSql query tuning or query optimization
Sql query tuning or query optimizationVivek Singh
ย 
Sql query tips or query optimization
Sql query tips or query optimizationSql query tips or query optimization
Sql query tips or query optimizationVivek Singh
ย 

More from Vivek Singh (20)

C programming session 14
C programming session 14C programming session 14
C programming session 14
ย 
C programming session 13
C programming session 13C programming session 13
C programming session 13
ย 
C programming session 11
C programming session 11C programming session 11
C programming session 11
ย 
C programming session 10
C programming session 10C programming session 10
C programming session 10
ย 
C programming session 08
C programming session 08C programming session 08
C programming session 08
ย 
C programming session 07
C programming session 07C programming session 07
C programming session 07
ย 
C programming session 05
C programming session 05C programming session 05
C programming session 05
ย 
C programming session 04
C programming session 04C programming session 04
C programming session 04
ย 
C programming session 02
C programming session 02C programming session 02
C programming session 02
ย 
C programming session 01
C programming session 01C programming session 01
C programming session 01
ย 
C programming session 16
C programming session 16C programming session 16
C programming session 16
ย 
Niit aptitude question paper
Niit aptitude question paperNiit aptitude question paper
Niit aptitude question paper
ย 
Excel shortcut and tips
Excel shortcut and tipsExcel shortcut and tips
Excel shortcut and tips
ย 
Sql where clause
Sql where clauseSql where clause
Sql where clause
ย 
Sql update statement
Sql update statementSql update statement
Sql update statement
ย 
Sql tutorial, tutorials sql
Sql tutorial, tutorials sqlSql tutorial, tutorials sql
Sql tutorial, tutorials sql
ย 
Sql subquery
Sql subquerySql subquery
Sql subquery
ย 
Sql rename
Sql renameSql rename
Sql rename
ย 
Sql query tuning or query optimization
Sql query tuning or query optimizationSql query tuning or query optimization
Sql query tuning or query optimization
ย 
Sql query tips or query optimization
Sql query tips or query optimizationSql query tips or query optimization
Sql query tips or query optimization
ย 

Recently uploaded

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
ย 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
ย 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
ย 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
ย 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
ย 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
ย 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
ย 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
ย 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
ย 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
ย 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
ย 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
ย 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
ย 

Recently uploaded (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
ย 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
ย 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
ย 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
ย 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
ย 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
ย 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
ย 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
ย 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
ย 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
ย 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
ย 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
ย 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
ย 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
ย 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
ย 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
ย 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
ย 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
ย 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
ย 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
ย 

Sql where clause

  • 1. 8/10/13 SQL WHERE Clause beginner-sql-tutorial.com/sql-where-clause.htm 1/2 SQL WHERE Clause The WHERE Clause is used when you want to retrieve specific information from a table excluding other irrelevant data. For example, when you want to see the information about students in class 10th only then you do need the information about the students in other class. Retrieving information about all the students would increase the processing time for the query. So SQL offers a feature called WHERE clause, which we can use to restrict the data that is retrieved. The condition you provide in the WHERE clause filters the rows retrieved from the table and gives you only those rows which you expected to see. WHERE clause can be used along with SELECT, DELETE, UPDATE statements. Syntax of SQL WHERE Clause: WHERE {column or expression} comparison-operator value Syntax for a WHERE clause with Select statement is: SELECT column_list FROM table-name WHERE condition; column or expression - Is the column of a table or a expression comparison-operator - operators like = < > etc. value - Any user value or a column name for comparison For Example: To find the name of a student with id 100, the query would be like: SELECT first_name, last_name FROM student_details WHERE id = 100; Comparison Operators and Logical Operators are used in WHERE Clause. These operators are discussed in the next chapter. NOTE: Aliases defined for the columns in the SELECT statement cannot be used in the WHERE clause to set
  • 2. 8/10/13 SQL WHERE Clause beginner-sql-tutorial.com/sql-where-clause.htm 2/2 conditions. Only aliases created for tables can be used to reference the columns in the table. How to use expressions in the WHERE Clause? Expressions can also be used in the WHERE clause of the SELECT statement. For example: Lets consider the employee table. If you want to display employee name, current salary, and a 20% increase in the salary for only those products where the percentage increase in salary is greater than 30000, the SELECT statement can be written as shown below SELECT name, salary, salary*1.2 AS new_salary FROM employee WHERE salary*1.2 > 30000; Output: name salarynew_salary -------- --- ------- --- -------------- -- Hrithik 35000 37000 Harsha 35000 37000 Priya 30000 360000 NOTE: Aliases defined in the SELECT Statement can be used in WHERE Clause.