Boolean operators
Introduction
Boolean operators allow you to test relational operator expressions.
Boolean operators
The operators you need to know are AND, OR and NOT. The result of a Boolean expression, like the result of a relational expression, will be either TRUE or FALSE.
Imagine that a = 1, b = 5, c = 5, d = 10. Study these examples:
(a >b) AND (c>a)
a>b is FALSE whilst c>a is TRUE. The overall expression is FALSE, however, because both halves of the AND must be TRUE. If one half or both halves are FALSE, then the overall statement is FALSE.
(a >b) OR (c>a)
a>b is FALSE whilst c>a is TRUE. The overall expression is TRUE, however, because only one half (or both parts) has to be TRUE. If both halves are FALSE, then the overall statement is FALSE.
(b=c) AND (d<=a)
(b=c) is TRUE whilst (d<=a) is FALSE. The overall expression is FALSE, however, because both halves of the AND must be TRUE. If one half or both halves are FALSE, then the overall statement is FALSE.
(b=c) OR (d<=a)
(b=c) is TRUE whilst (d<=a) is FALSE. The overall expression is TRUE, however, because only one half (or both parts) has to be TRUE. If both halves are FALSE, then the overall statement is FALSE.
NOT always goes to the left of a Boolean expression and inverts the result of the expression. If the expression evaluates to TRUE, then NOT makes the overall result FALSE. If the expression evaluates to FALSE, then NOT makes the overall result TRUE.
NOT (b=c)
(b=c) is TRUE. The overall result equates to FALSE, however, because of the NOT operator.
NOT(b>d)
(b>d) is FALSE. The overall result equates to TRUE, however, because of the NOT operator.