

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# オペレータ
<a name="iot-sql-operators"></a>

次の演算子は、SELECT 句および WHERE 句で使用できます。

## AND 演算子
<a name="iot-sql-operators-and"></a>

`Boolean` の結果を返します。論理 AND 演算を実行します。左右オペランドが true の場合は true を返します｡ それ以外の場合は、false を返します。`Boolean` オペランド、または、大文字小文字を区別しない「true」または「false」文字列オペランドが必要です。

*構文:* ` expression AND expression`


**AND 演算子**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Boolean | Boolean | Boolean。両方のオペランドが true の場合は true。それ以外の場合は、false を返します。 | 
| String/Boolean | String/Boolean | すべての文字列が「true」または「false」 (大文字と小文字が区別されません) の場合、それらは Boolean に変換され、boolean AND boolean として、正常に処理されます。 | 
| その他の値 | その他の値 | Undefined. | 

## OR 演算子
<a name="iot-sql-operators-or"></a>

`Boolean` の結果を返します。論理 OR 演算を実行します。左または右オペランドのいずれかが true の場合 true を返します。それ以外の場合は、false を返します。`Boolean` オペランド、または、大文字小文字を区別しない「true」または「false」文字列オペランドが必要です。

*構文:* ` expression OR expression`


**OR 演算子**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Boolean | Boolean | Boolean。どちらかのオペランドが true の場合は true。それ以外の場合は、false を返します。 | 
| String/Boolean | String/Boolean | すべての文字列が「true」または「false」 (大文字と小文字が区別されません) の場合、それらはブール値に変換され、boolean OR boolean として、正常に処理されます。 | 
| その他の値 | その他の値 | Undefined. | 

## NOT 演算子
<a name="iot-sql-operators-not"></a>

`Boolean` の結果を返します。論理 NOT 演算を実行します。オペランドが false の場合は true を返します｡ それ以外の場合は true を返します。`Boolean` オペランド、または、大文字小文字を区別しない「true」または「false」文字列オペランドが必要です。

*構文:* `NOT expression`


**NOT 演算子**  

| オペランド | 出力 | 
| --- | --- | 
| Boolean | Boolean。オペランドが false の場合は true｡ それ以外の場合は、true。 | 
| String | 文字列が「true」または「false」 (大文字と小文字は区別されません) の場合は、対応するブール値に変換され、反対の値は返されます。 | 
| その他の値 | Undefined. | 

## IN 演算子
<a name="iot-sql-operators-in"></a>

`Boolean` の結果を返します。WHERE 句の IN 演算子を使用して、値が配列内の値と一致するかどうかを確認できます。一致が見つかった場合は true、それ以外の場合は false を返します。

*構文:* ` expression IN expression`


**IN 演算子**  

| 左のオペランド | 右のオペランド | Output | 
| --- | --- | --- | 
| Int/Decimal/String/Array/Object | Array | Integer/Decimal/String/Array/Object 要素が配列で見つかった場合は true。それ以外の場合は、false を返します。 | 

*例*:

```
SQL: "select * from 'a/b' where 3 in arr"

JSON: {"arr":[1, 2, 3, "three", 5.7, null]}
```

この例では、`arr` という名前の配列に 3 が存在するため、条件句 `where 3 in arr` は true に評価されます。したがって、SQL ステートメントでは、`select * from 'a/b'` が実行されます。この例は、配列が異種である可能性も示しています。

## EXISTS 演算子
<a name="iot-sql-operators-exists"></a>

`Boolean` の結果を返します。EXISTS 演算子を条件句で使用して、サブクエリ内の要素の存在をテストできます。サブクエリが 1 つ以上の要素を返す場合は true を返し、サブクエリが要素を返さない場合は false を返します。

*構文:* ` expression`

*例*:

```
SQL: "select * from 'a/b' where exists (select * from arr as a where a = 3)"

JSON: {"arr":[1, 2, 3]}
```

この例では、`arr` という名前の配列に 3 が存在するため、条件句 `where exists (select * from arr as a where a = 3)` は true に評価されます。したがって、SQL ステートメントでは、`select * from 'a/b'` が実行されます。

*例*:

```
SQL: select * from 'a/b' where exists (select * from e as e where foo = 2)

JSON: {"foo":4,"bar":5,"e":[{"foo":1},{"foo":2}]}
```

この例では、JSON オブジェクト内の配列 `e` にオブジェクト `{"foo":2}` が含まれているため、条件句 `where exists (select * from e as e where foo = 2)` は true に評価されます。したがって、SQL ステートメントでは、`select * from 'a/b'` が実行されます。

## > operator
<a name="iot-sql-operators-greater"></a>

`Boolean` の結果を返します。左のオペランドが右のオペランドより大きい場合は true を返します。両方のオペランドが、`Decimal` に変換され、比較されます。

*構文:* `expression > expression`


**> operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int/Decimal | Int/Decimal | Boolean。左のオペランドが右のオペランドより大きい場合は true。それ以外の場合は、false を返します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列を Decimal に変換できると、その後は Boolean です。左のオペランドが右のオペランドより大きい場合は true を返します。それ以外の場合は、false を返します。 | 
| その他の値 | Undefined. | Undefined. | 

## >= operator
<a name="iot-sql-operators-greater-equal"></a>

`Boolean` の結果を返します。左のオペランドが右のオペランド以上の場合は true を返します。両方のオペランドが、`Decimal` に変換され、比較されます。

*構文:* `expression >= expression`


**>= operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int/Decimal | Int/Decimal | Boolean。左のオペランドが右のオペランド以上の場合は true。それ以外の場合は、false を返します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列を Decimal に変換できると、その後は Boolean です。左のオペランドが右のオペランド以上の場合は true を返します。それ以外の場合は、false を返します。 | 
| その他の値 | Undefined. | Undefined. | 

## < 演算子
<a name="iot-sql-operators-less"></a>

`Boolean` の結果を返します。左のオペランドが右のオペランド未満の場合は true を返します。両方のオペランドが、`Decimal` に変換され、比較されます。

*構文:* `expression < expression`


**< 演算子**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int/Decimal | Int/Decimal | Boolean。左のオペランドが右のオペランド未満の場合は true。それ以外の場合は、false を返します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列を Decimal に変換できると、その後は Boolean です。左のオペランドが右のオペランド未満の場合は true を返します。それ以外の場合は、false を返します。 | 
| その他の値 | Undefined | Undefined | 

## <= 演算子
<a name="iot-sql-operators-less-equal"></a>

`Boolean` の結果を返します。左のオペランドが右のオペランド以下の場合は true を返します。両方のオペランドが、`Decimal` に変換され、比較されます。

*構文:* `expression <= expression`


**<= 演算子**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int/Decimal | Int/Decimal | Boolean。左のオペランドが右のオペランド以下の場合は true。それ以外の場合は、false を返します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列を Decimal に変換できると、その後は Boolean です。左のオペランドが右のオペランド以下の場合は true を返します。それ以外の場合は、false を返します。 | 
| その他の値 | Undefined | Undefined | 

## <> 演算子
<a name="iot-sql-operators-not-eq"></a>

`Boolean` の結果を返します。左右オペランドの両方が等しくない場合に true を返します｡ それ以外の場合は、false を返します。

*構文:* ` expression <> expression`


**<> 演算子**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | 左のオペランドが右のオペランドと等しくなかったら true。それ以外の場合は、false を返します。 | 
| Decimal | Decimal | 左のオペランドが右のオペランドと等しくなかったら true。それ以外の場合は、false を返します。Int は比較される前に Decimal に変換されます。 | 
| String | String | 左のオペランドが右のオペランドと等しくなかったら true。それ以外の場合は、false を返します。 | 
| 配列 | 配列 | 各オペランドの項目が等しくなく、同じ順序でない場合、true。それ以外の場合は、false を返します。 | 
| オブジェクト | オブジェクト | 各オペランドのキーと値が等しくなかったら true。それ以外の場合は、false を返します。キーと値の順序は重要でありません。 | 
| Null | Null | False。 | 
| 任意の値 | Undefined | 未定義。 | 
| Undefined | 任意の値 | 未定義。 | 
| 不一致の型 | 不一致の型 | True。 | 

## = operator
<a name="iot-sql-operators-eq"></a>

`Boolean` の結果を返します。左右オペランドの両方が等しい場合に true を返します｡ それ以外の場合は、false を返します。

*構文:* ` expression = expression`


**= operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | 左のオペランドが右のオペランドと等しかったら true。それ以外の場合は、false を返します。 | 
| Decimal | Decimal | 左のオペランドが右のオペランドと等しかったら true。それ以外の場合は、false を返します。Int は比較される前に Decimal に変換されます。 | 
| String | String | 左のオペランドが右のオペランドと等しかったら true。それ以外の場合は、false を返します。 | 
| 配列 | 配列 | 各オペランドの項目が等しく、同じ順序の場合、true。それ以外の場合は、false を返します。 | 
| オブジェクト | オブジェクト | 各オペランドのキーと値が等しかったら true。それ以外の場合は、false を返します。キーと値の順序は重要でありません。 | 
| 任意の値 | Undefined | Undefined. | 
| Undefined | 任意の値 | Undefined. | 
| 不一致の型 | 不一致の型 | False。 | 

## \$1 operator
<a name="iot-sql-operators-plus"></a>

「\$1」は、オーバーロードされた演算子です。文字列の連結または追加に使用できます。

*構文:* ` expression + expression`


**\$1 operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| String | 任意の値 | 右のオペランドを文字列に変換してから、左のオペランドの末尾に連結します。 | 
| 任意の値 | String | 左のオペランドを文字列に変換して、右のオペランドを変換された左のオペランドの末尾に連結します。 | 
| Int | Int | Int 値。オペランドを共に追加します。 | 
| Int/Decimal | Int/Decimal | Decimal 値。オペランドを共に追加します。 | 
| その他の値 | その他の値 | Undefined. | 

## - operator
<a name="iot-sql-operators-sub"></a>

左のオペランドから右のオペランドを減算します。

*構文:* ` expression - expression`


**- operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | Int 値。左のオペランドから右のオペランドを減算します。 | 
| Int/Decimal | Int/Decimal | Decimal 値。左のオペランドから右のオペランドを減算します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列が小数に正しく変換されると、Decimal の値が返されます。左のオペランドから右のオペランドを減算します。それ以外の場合は Undefined を返します。 | 
| その他の値 | その他の値 | Undefined. | 
| その他の値 | その他の値 | Undefined. | 

## \$1 operator
<a name="iot-sql-operators-mult"></a>

左のオペランドを右のオペランドで乗算します。

*構文:* ` expression * expression`


**\$1 operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | Int 値。左のオペランドを右のオペランドで乗算します。 | 
| Int/Decimal | Int/Decimal | Decimal 値。左のオペランドを右のオペランドで乗算します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列が小数に正しく変換されると、Decimal の値が返されます。左のオペランドを右のオペランドで乗算します。それ以外の場合は Undefined を返します。 | 
| その他の値 | その他の値 | Undefined. | 

## / operator
<a name="iot-sql-operators-div"></a>

左のオペランドを右のオペランドで除算します。

*構文:* ` expression / expression`


**/ operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | Int 値。左のオペランドを右のオペランドで除算します。 | 
| Int/Decimal | Int/Decimal | Decimal 値。左のオペランドを右のオペランドで除算します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列が小数に正しく変換されると、Decimal の値が返されます。左のオペランドを右のオペランドで除算します。それ以外の場合は Undefined を返します。 | 
| その他の値 | その他の値 | Undefined. | 

## % operator
<a name="iot-sql-operators-mod"></a>

左のオペランドを右のオペランドで除算した剰余を返します。

*構文:* ` expression % expression`


**% operator**  

| 左のオペランド | 右のオペランド | 出力 | 
| --- | --- | --- | 
| Int | Int | Int 値。左のオペランドを右のオペランドで除算した剰余を返します。 | 
| String/Int/Decimal | String/Int/Decimal | すべての文字列が小数に正しく変換されると、Decimal の値が返されます。左のオペランドを右のオペランドで除算した剰余を返します。そうでない場合は、Undefined です。 | 
| その他の値 | その他の値 | Undefined. | 