Arithmetic Operators
Arithmetic operators are used to perform arithmetic between operands
Given that y = 5, the table below explains the arithmetic operators:
Operator | Description | Example | Results |
---|---|---|---|
+ |
Addition | y + 2 | 7 |
- |
Subtraction | y - 2 | 3 |
* |
Multiplication | y * 2 | 10 |
/ |
Division | y / 2 | 2.5 |
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between operands.
Equals and not equals will work on all data types, less then/or equal and greater then/or equal will only work on numbers or datetimes
Given that x = 5, the table below explains the arithmetic operators:
Operator | Description | Comparing | Returns |
---|---|---|---|
== |
equal to | x == 8 | false |
x == 5 | true | ||
!= |
not equal | x != 8 | true |
> |
greater than | x > 8 | false |
< |
less than | x < 8 | true |
>= |
greater than or equal to | x >= 8 | false |
<= |
less than or equal to | x <= 8 | true |
Logical Operators
Logical operators are used to determine the logic between operands
Given that x = 6 and y = 3, the table below explains the arithmetic operators:
Operator | Description | Example | Results |
---|---|---|---|
&& |
And | (x < 10) && (y > 1) | true |
|| |
Or | (x == 5) || (y == 5) | false |
! |
Not - The single operand must be contained in parenthesis | !(x == y) | false |
SQL Comparison Operators
Operator | Description | Comparing | Returns |
---|---|---|---|
is |
The is operator compares the left hand side operand which can be of any type with the value null/undefined. The left hand operand must always be the reserved word null. Given that x = null, y = 5 and z = 'a' |
x is null | true |
y is null | false | ||
z is null | false | ||
in |
The in operator will test if the left hand side operand is equal to any of the values in the right hand side operands list. The right hand side operands list must be contained in parenthesis. Given that x = 'a' and y = 5 |
x in ('a','b','c') | true |
y in (1, 2, 3) | false | ||
like |
The like operator will test if the left hand side operand matches part of the right hand side operand. The right hand side operands uses the % symbol as a wildcard to represents zero, one, or multiple characters Given that x = 'abcdef' |
x like 'abc%' | false |
x like '%abc' | false | ||
x like '%d%' | true |
String Operators
The & operator is used to concatenate strings.
Given that text1 = 'Good', text2 = 'Morning' the table below explains the operators:
Operator | Description | Example | Result in |
---|---|---|---|
& |
Concatenation | text1 & ' ' & text2 | 'Good Morning' |