Combined Conditions
Two or more conditions can be logically connected to form a combined condition.
Combined Conditions - Format .----------------------. V | >>-condition-1----+-AND-+--condition-2-+----------------------->< '-OR--'
- A simple-condition
- A negated simple-condition
- A combined condition
- A negated combined condition (that is, the NOT logical operator followed by a combined condition enclosed in parentheses)
- Combinations of the preceding conditions, specified according to the rules in the following table.
| Combined condition element | Leftmost | When not leftmost, can be immediately preceded by: | Rightmost | When not rightmost, can be immediately followed by: |
|---|---|---|---|---|
| simple-condition | Yes | OR |
Yes | OR |
OR |
No | simple-condition |
No | simple-condition |
| NOT | Yes | OR |
No | simple-condition |
| ( | Yes | OR |
No | simple-condition |
| ) | No | simple-condition |
Yes | OR |
Parentheses are never needed when either ANDs or ORs (but not both) are used exclusively in one combined condition. However, parentheses may be needed to modify the implicit precedence rules to maintain the correct logical relation of operators and operands.
There must be a one-to-one correspondence between left and right parentheses, with each left parenthesis to the left of its corresponding right parenthesis.
The following table illustrates the relationships between logical operators and conditions C1 and C2.
| Value for C1 | Value for C2 | C1 AND C2 | C1 OR C2 | NOT (C1 AND C2) | NOT C1 AND C2 | NOT (C1 OR C2) | NOT C1 OR C2 |
|---|---|---|---|---|---|---|---|
| True | True | True | True | False | False | False | True |
| False | True | False | True | True | True | False | True |
| True | False | False | True | True | False | False | False |
| False | False | False | False | True | False | True | True |
