Operators are symbols and keywords that specify an operation to be performed on one or more value expressions.
Arithmetic operators
The arithmetic operators perform operations on numeric values.
Operator |
Symbol |
Operation |
<addition operator> |
+ |
Addition |
<subtraction operator> |
- |
Subtraction |
<multiplication operator> |
* |
Multiplication |
<division operator> |
/ |
Division |
Note: The addition (+) and subtraction (-) operators are also used in arithmetic operations on datetime values.
See also: Numeric Value Functions.
The concatenation operator is used to concatenate string values.
Operator |
Symbol |
Operation |
<concatenation operator> |
|| |
String concatenation |
Note: The arithmetic addition (+) operator can be used as an alternate string concatenation operator.
See also: String Value Functions.
The comparison operators are used in some predicates to specify comparison tests.
Operator |
Symbol |
Operation |
<equals operator> |
= |
Equal to |
<not equals operator> |
<> |
Not equal to |
<less than operator> |
< |
Less than |
<greater than operator> |
> |
Greater than |
<less than or equals operator> |
<= |
Less than or equal to |
<greater than or equals operator> |
>= |
Greater than or equal to |
Note: The equals sign (=) is also used as an assignment operator.
The boolean operators are used to combine predicates in search conditions.
Operator |
Keyword |
Operation |
<boolean NOT operator> |
NOT |
Invert the result of the boolean test |
<boolean AND operator> |
AND |
Test if both predicates are TRUE |
<boolean OR operator> |
OR |
Test if either of the predicates is TRUE |
Note: Check the truth tables to see how combined boolean expressions are evaluated.
The equals sign is used for value assignments.
Operator |
Symbol |
Operation |
<assignment operator> |
= |
Value assignment |
Operator precedence determines the order in which operations are performed during the execution of a complex value expression with multiple operators.
Operators are evaluated in the following order, ranked from highest to lowest precedence level:
♦ | * (multiplication), / (division) |
♦ | + (addition), - (subtraction) |
♦ | ||, + (concatenation) |
♦ | =, <>, <, >, <=, >= (comparison operators) |
♦ | NOT |
♦ | AND |
♦ | OR |
Operators on the same precedence level are evaluated left to right based on their position in the value expression.
If a value expression has nested parentheses, the innermost expression is evaluated first.
Tip: Instead of relying on the defined operator precedence, it is recommended to use parentheses to explicitly specify the order of operations in complex value expressions with many operators. All operations inside parentheses are evaluated first to yield a single value before that value is used as an operand in other operations.
Conformance
SQL:2003 standard NexusDB extensions |
- - |
Core SQL Plus sign as string concatenation operator |