Precedence Among Operators
Go Up to Determining Precedence of Operators
Among Operators of Different Types
The following table lists the evaluation order of different InterBase operator types, from first evaluated (highest precedence) to last evaluated (lowest precedence):
Operator type  Precedence  Explanation 

String 
Highest 
Strings are always concatenated before all other operations take place. 
Mathematical 
ﬂ 
Math is performed after string concatenation, but before comparison and logical operations. 
Comparison 
ﬂ 
Comparison operations are evaluated after string concatenation and math, but before logical operations. 
Logical 
Lowest 
Logical operations are evaluated after all other operations. 
Among Operators of the Same Type
When an expression contains several operators of the same type, those operators are evaluated from left to right unless there is a conflict where two operators of the same type affect the same values.
For example, in the mathematical equation, 3 + 2 * 6, both the addition and multiplication operators work with the same value, 2. Evaluated from left to right, the equation evaluates to 30: 3+ 2 = 5; 5 * 6 = 30. InterBase follows standard mathematical rules for evaluating mathematical expressions, that stipulate multiplication is performed before addition: 2 *6 = 12; 3 + 12 = 15.
The following table lists the evaluation order for all mathematical operators, from highest to lowest:
Operator  Precedence  Explanation 

* 
Highest 
Multiplication is performed before all other mathematical operations. 
/ 
ﬂ 
Division is performed before addition and subtraction. 
+ 
ﬂ 
Addition is performed before subtraction. 
– 
Lowest 
Subtraction is performed after all other mathematical operations. 
InterBase also follows rules for determining the order in which comparison operators are evaluated when conflicts arise during normal left to right evaluation. The next table describes the evaluation order for comparison operators, from highest to lowest:
Operator  Precedence  Explanation 

=,== 
Highest 
Equality operations are evaluated before all other comparison operations. 
<>, !=, ~=, ^= 
ﬂ 

> 
ﬂ 

< 
ﬂ 

>= 
ﬂ 

<= 
ﬂ 

>, ~>, ^> 
ﬂ 

<, ~<, ^< 
Lowest 
Not less than operations are evaluated after all other comparison operations. 
ALL
, ANY
, BETWEEN
, CONTAINING
, EXISTS
, IN
, LIKE
, NULL
, SINGULAR
, SOME
, and STARTING WITH
are evaluated after all listed comparison operators when they conflict with other comparison operators during normal left to right evaluation. When they conflict with one another they are evaluated strictly from left to right.
When logical operators conflict during normal left to right processing, they, too, are evaluated according to a hierarchy, detailed in the following table:
Operator  Precedence  Explanation 

NOT 
Highest 
NOT operations are evaluated before all other logical operations. 
AND 
ﬂ 
AND operations are evaluated after NOT operations, and before OR operations. 
OR 
Lowest 
OR operations are evaluated after all other logical operations. 