SlideShare una empresa de Scribd logo
1 de 20
SQL Logical Operators
DATABASE SYSTEM2
ANGELO T. RETITA
IT-INSTRCTOR
Objectives
 1. To determine what are the Logical Operators in
SQL.
 2. To understand the usage of Logical Operators.
 3. To understand the syntax of the Logical Operators.
 4. To understand the importance of the Logical
Operators.
What is
Logical
Operator?
a programming-language symbol
that denotes a logical operation.
SQLLogical
Operators
 There are three Logical Operators namely, AND, OR,
and NOT.
 These operators compare two conditions at a time to
determine whether a row can be selected for the
output.
 When retrieving data using a SELECT statement, you
can use logical operators in the WHERE clause, which
allows you to combine more than one condition.
SQLLogical
Operators
Logical
Operators
Description
OR
For the row to be selected at least one of the
conditions must be true.
AND
For a row to be selected all the specified
conditions must be true.
NOT
For a row to be selected the specified condition
must be false.
"OR"Logical
OperatorSyntax
 SELECT column1, column2, ...
FROM table_name
WHERE condition1 OR condition2 OR condition3 ...;
Whentouse
"OR"Logical
Operator?
 If you want to select rows that satisfy at least one of
the given conditions, you can use the logical operator,
OR.
DemoDatabase
 Below is a selection from the "Customers" table in the
Northwind sample database:
CustomerID CustomerNa
me
ContactNam
e
Address City PostalCode Country
1 Alfreds
Futterkiste
Maria
Anders
Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedado
s y helados
Ana Trujillo Avda. de la
Constitución
2222
México D.F. 05021 Mexico
3 Antonio
Moreno
Taquería
Antonio
Moreno
Mataderos
2312
México D.F. 05023 Mexico
4 Around the
Horn
Thomas
Hardy
120 Hanover
Sq.
London WA1 1DP UK
5 Berglunds
snabbköp
Christina
Berglund
Berguvsväge
n 8
Luleå S-958 22 Sweden
"OR"Logical
Operator
Example
 The following SQL statement selects all fields from
"Customers" where city is "Berlin" OR "München":
SELECT * FROM Customers
WHERE City='Berlin' OR City='München';
"OR"Operator
Table
 The following table describes how logical "OR" operator
selects a row.
Column1
Satisfied?
Column2
Satisfied?
Row Selected
YES YES YES
YES NO YES
NO YES YES
NO NO NO
“AND"Logical
OperatorSyntax
 SELECT column1, column2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3
...;
Whentouse
"AND"Logical
Operator?
 If you want to select rows that must satisfy all the
given conditions, you can use the logical operator, AND.
DemoDatabase
 Below is a selection from the "Customers" table in the
Northwind sample database:
CustomerID CustomerNa
me
ContactNam
e
Address City PostalCode Country
1 Alfreds
Futterkiste
Maria
Anders
Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedado
s y helados
Ana Trujillo Avda. de la
Constitución
2222
México D.F. 05021 Mexico
3 Antonio
Moreno
Taquería
Antonio
Moreno
Mataderos
2312
México D.F. 05023 Mexico
4 Around the
Horn
Thomas
Hardy
120 Hanover
Sq.
London WA1 1DP UK
5 Berglunds
snabbköp
Christina
Berglund
Berguvsväge
n 8
Luleå S-958 22 Sweden
"AND"Logical
Operator
Example
 The following SQL statement selects all fields from
"Customers" where city is "Berlin" OR "München":
SELECT * FROM Customers
WHERE Country='Germany' AND City='Berlin';
“AND"Operator
Table
 The following table describes how logical "OR" operator
selects a row.
Column1
Satisfied?
Column2
Satisfied?
Row Selected
YES YES YES
YES NO NO
NO YES NO
NO NO NO
“NOT"Logical
OperatorSyntax
 SELECT column1, column2, ...
FROM table_name
WHERE NOT condition;
Whentouse
“NOT"Logical
Operator?
 If you want to find rows that do not satisfy a condition,
you can use the logical operator, NOT. NOT results in
the reverse of a condition. That is, if a condition is
satisfied, then the row is not returned.
DemoDatabase
 Below is a selection from the "Customers" table in the
Northwind sample database:
CustomerID CustomerNa
me
ContactNam
e
Address City PostalCode Country
1 Alfreds
Futterkiste
Maria
Anders
Obere Str. 57 Berlin 12209 Germany
2 Ana Trujillo
Emparedado
s y helados
Ana Trujillo Avda. de la
Constitución
2222
México D.F. 05021 Mexico
3 Antonio
Moreno
Taquería
Antonio
Moreno
Mataderos
2312
México D.F. 05023 Mexico
4 Around the
Horn
Thomas
Hardy
120 Hanover
Sq.
London WA1 1DP UK
5 Berglunds
snabbköp
Christina
Berglund
Berguvsväge
n 8
Luleå S-958 22 Sweden
“NOT"Logical
Operator
Example
 The following SQL statement selects all fields from
"Customers" where country is NOT "Germany" and
NOT "USA":
SELECT * FROM Customers
WHERE NOT Country='Germany' AND NOT Country='USA';
“NOT"Operator
Table
 The following table describes how logical "OR" operator
selects a row.
Column1
Satisfied?
NOT
Column1
Satisfied?
Row Selected
YES NO NO
NO YES YES

Más contenido relacionado

La actualidad más candente

Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
Nargis Ehsan
 
Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulas
LearnIT@UD
 

La actualidad más candente (18)

Devry bis 155 week 1 quiz data analysis with spreadsheets with lab
Devry bis 155 week 1 quiz data analysis with spreadsheets with labDevry bis 155 week 1 quiz data analysis with spreadsheets with lab
Devry bis 155 week 1 quiz data analysis with spreadsheets with lab
 
Get more from excel
Get more from excelGet more from excel
Get more from excel
 
Join sql
Join sqlJoin sql
Join sql
 
Les04
Les04Les04
Les04
 
New Dynamic Array Functions. Excel Tutorial
New Dynamic Array Functions. Excel TutorialNew Dynamic Array Functions. Excel Tutorial
New Dynamic Array Functions. Excel Tutorial
 
Ms excel
Ms excelMs excel
Ms excel
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Les05
Les05Les05
Les05
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
9 case
9 case9 case
9 case
 
Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulas
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 
Simple formulas excel
Simple formulas excelSimple formulas excel
Simple formulas excel
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQL
 

Similar a 3. sql logical operators

Similar a 3. sql logical operators (20)

Book HH - SQL MATERIAL
Book   HH - SQL MATERIALBook   HH - SQL MATERIAL
Book HH - SQL MATERIAL
 
DBMS
DBMSDBMS
DBMS
 
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
 
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
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
about-SQL AND ETC.pptx
about-SQL AND ETC.pptxabout-SQL AND ETC.pptx
about-SQL AND ETC.pptx
 
Sql
SqlSql
Sql
 
Oracle: Cursors
Oracle: CursorsOracle: Cursors
Oracle: Cursors
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Advanced MySQL Query Optimizations
Advanced MySQL Query OptimizationsAdvanced MySQL Query Optimizations
Advanced MySQL Query Optimizations
 
SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Sql ch 5
Sql ch 5Sql ch 5
Sql ch 5
 
kupdf.net_sql-ebook-w3schoolscom.pdf
kupdf.net_sql-ebook-w3schoolscom.pdfkupdf.net_sql-ebook-w3schoolscom.pdf
kupdf.net_sql-ebook-w3schoolscom.pdf
 
ADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptxADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptx
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Oracle: Basic SQL
Oracle: Basic SQLOracle: Basic SQL
Oracle: Basic SQL
 
Intro to SQL by Google's Software Engineer
Intro to SQL by Google's Software EngineerIntro to SQL by Google's Software Engineer
Intro to SQL by Google's Software Engineer
 
SQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfSQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdf
 

Más de 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
 

Último

%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
masabamasaba
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Último (20)

WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 

3. sql logical operators

  • 1. SQL Logical Operators DATABASE SYSTEM2 ANGELO T. RETITA IT-INSTRCTOR
  • 2. Objectives  1. To determine what are the Logical Operators in SQL.  2. To understand the usage of Logical Operators.  3. To understand the syntax of the Logical Operators.  4. To understand the importance of the Logical Operators.
  • 3. What is Logical Operator? a programming-language symbol that denotes a logical operation.
  • 4. SQLLogical Operators  There are three Logical Operators namely, AND, OR, and NOT.  These operators compare two conditions at a time to determine whether a row can be selected for the output.  When retrieving data using a SELECT statement, you can use logical operators in the WHERE clause, which allows you to combine more than one condition.
  • 5. SQLLogical Operators Logical Operators Description OR For the row to be selected at least one of the conditions must be true. AND For a row to be selected all the specified conditions must be true. NOT For a row to be selected the specified condition must be false.
  • 6. "OR"Logical OperatorSyntax  SELECT column1, column2, ... FROM table_name WHERE condition1 OR condition2 OR condition3 ...;
  • 7. Whentouse "OR"Logical Operator?  If you want to select rows that satisfy at least one of the given conditions, you can use the logical operator, OR.
  • 8. DemoDatabase  Below is a selection from the "Customers" table in the Northwind sample database: CustomerID CustomerNa me ContactNam e Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedado s y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsväge n 8 Luleå S-958 22 Sweden
  • 9. "OR"Logical Operator Example  The following SQL statement selects all fields from "Customers" where city is "Berlin" OR "München": SELECT * FROM Customers WHERE City='Berlin' OR City='München';
  • 10. "OR"Operator Table  The following table describes how logical "OR" operator selects a row. Column1 Satisfied? Column2 Satisfied? Row Selected YES YES YES YES NO YES NO YES YES NO NO NO
  • 11. “AND"Logical OperatorSyntax  SELECT column1, column2, ... FROM table_name WHERE condition1 AND condition2 AND condition3 ...;
  • 12. Whentouse "AND"Logical Operator?  If you want to select rows that must satisfy all the given conditions, you can use the logical operator, AND.
  • 13. DemoDatabase  Below is a selection from the "Customers" table in the Northwind sample database: CustomerID CustomerNa me ContactNam e Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedado s y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsväge n 8 Luleå S-958 22 Sweden
  • 14. "AND"Logical Operator Example  The following SQL statement selects all fields from "Customers" where city is "Berlin" OR "München": SELECT * FROM Customers WHERE Country='Germany' AND City='Berlin';
  • 15. “AND"Operator Table  The following table describes how logical "OR" operator selects a row. Column1 Satisfied? Column2 Satisfied? Row Selected YES YES YES YES NO NO NO YES NO NO NO NO
  • 16. “NOT"Logical OperatorSyntax  SELECT column1, column2, ... FROM table_name WHERE NOT condition;
  • 17. Whentouse “NOT"Logical Operator?  If you want to find rows that do not satisfy a condition, you can use the logical operator, NOT. NOT results in the reverse of a condition. That is, if a condition is satisfied, then the row is not returned.
  • 18. DemoDatabase  Below is a selection from the "Customers" table in the Northwind sample database: CustomerID CustomerNa me ContactNam e Address City PostalCode Country 1 Alfreds Futterkiste Maria Anders Obere Str. 57 Berlin 12209 Germany 2 Ana Trujillo Emparedado s y helados Ana Trujillo Avda. de la Constitución 2222 México D.F. 05021 Mexico 3 Antonio Moreno Taquería Antonio Moreno Mataderos 2312 México D.F. 05023 Mexico 4 Around the Horn Thomas Hardy 120 Hanover Sq. London WA1 1DP UK 5 Berglunds snabbköp Christina Berglund Berguvsväge n 8 Luleå S-958 22 Sweden
  • 19. “NOT"Logical Operator Example  The following SQL statement selects all fields from "Customers" where country is NOT "Germany" and NOT "USA": SELECT * FROM Customers WHERE NOT Country='Germany' AND NOT Country='USA';
  • 20. “NOT"Operator Table  The following table describes how logical "OR" operator selects a row. Column1 Satisfied? NOT Column1 Satisfied? Row Selected YES NO NO NO YES YES