1.8

AND, OR, NOT Logical Operators

AND, OR, NOT Logical Operators

• Logical operators are used in the WHERE clause
• You may use multiple logical operators in a WHERE clause to create a Compound condition. The order of evaluation when multiple operators are used is shown in the table above.

Table 6. Logical Operators

 Operator Description Order of Evaluation NOT ( a NOT b ) – a must be present but b must NOT be present to be included 1 AND ( a AND b ) –If  both a and b are present, item is included 2 OR ( a OR b ) – If either a OR b is present item is included 3

Example:

USE world;SELECT name, populationFROM countryWHERE region = 'caribbean'AND population > 100000ORDER BY population ASC;

Results:

CC BY-NC-ND International 4.0: This work is released under a CC BY-NC-ND International 4.0 license, which means that you are free to do with it as you please as long as you (1) properly attribute it, (2) do not use it for commercial gain, and (3) do not create derivative works.

End-of-Chapter Survey

: How would you rate the overall quality of this chapter?
1. Very Low Quality
2. Low Quality
3. Moderate Quality
4. High Quality
5. Very High Quality
Comments will be automatically submitted when you navigate away from the page.