Operators - AWS IoT Core

Operators

The following operators can be used in SELECT and WHERE clauses.

AND operator

Returns a Boolean result. Performs a logical AND operation. Returns true if left and right operands are true. Otherwise, returns false. Boolean operands or case insensitive "true" or "false" string operands are required.

Syntax: expression AND expression.

AND operator
Left operand Right operand Output
Boolean Boolean Boolean. True if both operands are true. Otherwise, false.
String/Boolean String/Boolean If all strings are "true" or "false" (case insensitive), they are converted to Boolean and processed normally as boolean AND boolean.
Other value Other value Undefined.

OR operator

Returns a Boolean result. Performs a logical OR operation. Returns true if either the left or the right operands are true. Otherwise, returns false. Boolean operands or case insensitive "true" or "false" string operands are required.

Syntax: expression OR expression.

OR operator
Left operand Right operand Output
Boolean Boolean Boolean. True if either operand is true. Otherwise, false.
String/Boolean String/Boolean If all strings are "true" or "false" (case insensitive), they are converted to Booleans and processed normally as boolean OR boolean.
Other value Other value Undefined.

NOT operator

Returns a Boolean result. Performs a logical NOT operation. Returns true if the operand is false. Otherwise, returns true. A Boolean operand or case insensitive "true" or "false" string operand is required.

Syntax: NOT expression.

NOT operator
Operand Output
Boolean Boolean. True if operand is false. Otherwise, true.
String If string is "true" or "false" (case insensitive), it is converted to the corresponding Boolean value, and the opposite value is returned.
Other value Undefined.

> operator

Returns a Boolean result. Returns true if the left operand is greater than the right operand. Both operands are converted to a Decimal, and then compared.

Syntax: expression > expression.

> operator
Left operand Right operand Output
Int/Decimal Int/Decimal Boolean. True if the left operand is greater than the right operand. Otherwise, false.
String/Int/Decimal String/Int/Decimal If all strings can be converted to Decimal, then Boolean. Returns true if the left operand is greater than the right operand. Otherwise, false.
Other value Undefined. Undefined.

>= operator

Returns a Boolean result. Returns true if the left operand is greater than or equal to the right operand. Both operands are converted to a Decimal, and then compared.

Syntax: expression >= expression.

>= operator
Left operand Right operand Output
Int/Decimal Int/Decimal Boolean. True if the left operand is greater than or equal to the right operand. Otherwise, false.
String/Int/Decimal String/Int/Decimal If all strings can be converted to Decimal, then Boolean. Returns true if the left operand is greater than or equal to the right operand. Otherwise, false.
Other value Undefined. Undefined.

< operator

Returns a Boolean result. Returns true if the left operand is less than the right operand. Both operands are converted to a Decimal, and then compared.

Syntax: expression < expression.

< operator
Left operand Right operand Output
Int/Decimal Int/Decimal Boolean. True if the left operand is less than the right operand. Otherwise, false.
String/Int/Decimal String/Int/Decimal If all strings can be converted to Decimal, then Boolean. Returns true if the left operand is less than the right operand. Otherwise, false.
Other value Undefined Undefined

<= operator

Returns a Boolean result. Returns true if the left operand is less than or equal to the right operand. Both operands are converted to a Decimal, and then compared.

Syntax: expression <= expression.

<= operator
Left operand Right operand Output
Int/Decimal Int/Decimal Boolean. True if the left operand is less than or equal to the right operand. Otherwise, false.
String/Int/Decimal String/Int/Decimal If all strings can be converted to Decimal, then Boolean. Returns true if the left operand is less than or equal to the right operand. Otherwise, false.
Other value Undefined Undefined

<> operator

Returns a Boolean result. Returns true if both left and right operands are not equal. Otherwise, returns false.

Syntax: expression <> expression.

<> operator
Left operand Right operand Output
Int Int True if left operand is not equal to right operand. Otherwise, false.
Decimal Decimal True if left operand is not equal to right operand. Otherwise, false.Int is converted to Decimal before being compared.
String String True if left operand is not equal to right operand. Otherwise, false.
Array Array True if the items in each operand are not equal and not in the same order. Otherwise, false
Object Object True if the keys and values of each operand are not equal. Otherwise, false. The order of keys/values is unimportant.
Null Null False.
Any value Undefined Undefined.
Undefined Any value Undefined.
Mismatched type Mismatched type True.

= operator

Returns a Boolean result. Returns true if both left and right operands are equal. Otherwise, returns false.

Syntax: expression = expression.

= operator
Left operand Right operand Output
Int Int True if left operand is equal to right operand. Otherwise, false.
Decimal Decimal True if left operand is equal to right operand. Otherwise, false.Int is converted to Decimal before being compared.
String String True if left operand is equal to right operand. Otherwise, false.
Array Array True if the items in each operand are equal and in the same order. Otherwise, false.
Object Object True if the keys and values of each operand are equal. Otherwise, false. The order of keys/values is unimportant.
Any value Undefined Undefined.
Undefined Any value Undefined.
Mismatched type Mismatched type False.

+ operator

The "+" is an overloaded operator. It can be used for string concatenation or addition.

Syntax: expression + expression.

+ operator
Left operand Right operand Output
String Any value Converts the right operand to a string and concatenates it to the end of the left operand.
Any value String Converts the left operand to a string and concatenates the right operand to the end of the converted left operand.
Int Int Int value. Adds operands together.
Int/Decimal Int/Decimal Decimal value. Adds operands together.
Other value Other value Undefined.

- operator

Subtracts the right operand from the left operand.

Syntax: expression - expression.

- operator
Left operand Right operand Output
Int Int Int value. Subtracts right operand from left operand.
Int/Decimal Int/Decimal Decimal value. Subtracts right operand from left operand.
String/Int/Decimal String/Int/Decimal If all strings convert to decimals correctly, a Decimal value is returned. Subtracts right operand from left operand. Otherwise, returns Undefined.
Other value Other value Undefined.
Other value Other value Undefined.

* operator

Multiplies the left operand by the right operand.

Syntax: expression * expression.

* operator
Left operand Right operand Output
Int Int Int value. Multiplies the left operand by the right operand.
Int/Decimal Int/Decimal Decimal value. Multiplies the left operand by the right operand.
String/Int/Decimal String/Int/Decimal If all strings convert to decimals correctly, a Decimal value is returned. Multiplies the left operand by the right operand. Otherwise, returns Undefined.
Other value Other value Undefined.

/ operator

Divides the left operand by the right operand.

Syntax: expression / expression.

/ operator
Left operand Right operand Output
Int Int Int value. Divides the left operand by the right operand.
Int/Decimal Int/Decimal Decimal value. Divides the left operand by the right operand.
String/Int/Decimal String/Int/Decimal If all strings convert to decimals correctly, a Decimal value is returned. Divides the left operand by the right operand. Otherwise, returns Undefined.
Other value Other value Undefined.

% operator

Returns the remainder from dividing the left operand by the right operand.

Syntax: expression % expression.

% operator
Left operand Right operand Output
Int Int Int value. Returns the remainder from dividing the left operand by the right operand.
String/Int/Decimal String/Int/Decimal If all strings convert to decimals correctly, a Decimal value is returned. Returns the remainder from dividing the left operand by the right operand. Otherwise, Undefined.
Other value Other value Undefined.