Rules of Precedence for Operators

Rules of Precedence for Operators

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

Rules of Precedence for Operators

Operator

Rule of Precedence

Conditional Operators

are evaluated first

NOT

NOT is evaluated first.

AND

AND is evaluated next.

OR, XOR

OR and XOR are evaluated last.

Note: Operators of equal precedence are evaluated from left to right in the expression.
Parentheses can be used to explicitly determine the order of evaluation, overriding the order described above. Each pair of parentheses can contain only one Boolean expression. For example:
not (Salary > 4500 xor LastName = ‘Smith’)
causes the XOR expression to be evaluated before the NOT.

Examples

Some examples of Boolean expressions are shown below:

DeptNum=’Sports’ and Salary > 45000 and LastName = ‘Smith’

Logically true when all three conditional expressions are true; otherwise, logically false.

LastName = ‘Allan’ or Firstname = ‘Allan’

Logically true when either of the conditional expressions is true; otherwise, logically false.

not Salary > 45000

Logically true when the conditional expression is logically false and vice versa.

not ProdCode between 542 and 863

Logically true when the conditional expression is logically false and vice versa.

not LastName in (‘Smith’, ‘Jones’)

Logically true when the conditional expression is logically false and vice versa.

not FirstName like ‘ Sm%’

Logically true when the conditional expression is logically false and vice versa.

Was this article helpful?
0 out of 5 stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

pt_BRPortuguese