Database Operators and Operands

 Logical Operators

 Introduction

Databases and other programming environments provide operators you can use to perform data analysis. The operators used are called logical operators because they are used to perform comparisons that produce a result of true or false (there is no middle result: something is not half true or half false or "Don't Know"; either it is true or it is false).

 The Equality =

The equality operator is used to compare two values for similarity. The syntax of this operation is:

Value1 = Value2

If Value1 and Value2 hold the same value, then the comparison produces a True result. If they hold different values, the comparison renders a False value

 Inequality <>

To find out if two fields hold different values, you can use the inequality operator which is represented by <>. Its syntax is:

Value1 <> Value2

This comparison is performed between Value1 and Value2. If they hold different values, then the comparison produces a True value (make sure you understand this property of Boolean algebra). If they hold the same value, the comparison produces False:

This shows you that the equality (=) and the inequality (<>) operators are opposite each other.

 Less Than <
 The "Less Than" operator uses the following syntax: Value1 < Value2 If Value1 holds a value that is lower than that of Value2, the comparison produces True. If Value1 holds a value that is greater or similar to that of Value2, the comparison renders false:

 Less Than Or Equal <=

When comparing two values, you may want to know whether two fields hold the same value or if one is lower than the other. This comparison can be performed with the "Less Than Or Equal To" operator. It is represented by <=. Its syntax is:

`Value1 <= Value2`

If both operands (Value1 and Value2) hold the same value, then the comparison produces a True result. If Value1 holds a value that is lower than that of Value2, the comparison still produces a True result. By contrast, if the value of Value1 is higher than that of Value2, the comparison renders a False result:

Note that the > and the <= operators are opposite each other.

 Logical Operators: Greater Than >
 The > operator is used to find out whether one value is "Greater Than" another. Its syntax is: `Value1 > Value2` The operation is performed on the values of Value1 and Value2. If Value1 holds a value greater than that of Value2, then the comparison produces True. Otherwise, the comparison produces False. That is, if the value of Value2 is greater than or equal to that of Value1, then the comparison produces False:

 Greater Then Or Equal >=

If you have two values and want to find out whether they hold similar values or the first is greater than the second, you can use the >= operator whose syntax is:

`Value1 >= Value2`

If both Value1 and Value2 hold the same value, then the comparison renders a True result. Similarly, if the left operand, Value1, holds a value greater than that of the right operand, Value2, the comparison still produces True. If the value of Value1 is less than the value of Value2, the comparison produces a False result:

Therefore, < and >= are opposite.

 The NOT Operator
 To deny the presence, the availability, or the existence of a value, you can use the Not operator. This operator is primarily used to reverse a Boolean value. For example, we have learned that False is the opposite of True. In the same way, True is the opposite of False. If you want to compare a value as not being True, the Not True expression would produce the same result as the False value. For the same reason, the expression Not False is the same as True.
 The IS Operator
 To validate something as being possible, you can use the IS operator. For example, to acknowledge that something is NULL, you can use the IS NULL expression. In the same way, to validate that something is not null, you can use the expression Is Not NULL.
 The IN Operator
 The IN operator is used to check whether a record or a group of records is found in a group.