Mapping judgment functions/operators evaluate the mapped data of an input and return a Boolean value. OceanBase AI Database currently supports the = and != operators.
=/!=
= and != are used to determine whether two mapped data are equal. The syntax is as follows:
map1 = map2;
map1 != map2;
The input parameters are described as follows:
- The type passed to
map1must be a mapping type. - The type passed to
map2must be a mapping type.
The return result is described as follows:
- For
=,1indicates equality, and0indicates inequality. - For
!=,0indicates equality, and1indicates inequality. - A map is considered equal only when both the key and value are equal.
An example is as follows:
SELECT map(1,"a",2,"b") = map(1,"a",2,"b");
+-------------------------------------+
| map(1,"a",2,"b") = map(1,"a",2,"b") |
+-------------------------------------+
| 1 |
+-------------------------------------+
1 row in set
-- During comparison, the system automatically converts arrays to comparable types.
SELECT map(1,"a",2,"b") = map("1","a","2","b");
+-----------------------------------------+
| map(1,"a",2,"b") = map("1","a","2","b") |
+-----------------------------------------+
| 1 |
+-----------------------------------------+
1 row in set
-- 0 when the keys are equal but the values are not
SELECT map(1,"a",2,"b") = map(1,"a",2,"c");
+-------------------------------------+
| map(1,"a",2,"b") = map(1,"a",2,"c") |
+-------------------------------------+
| 0 |
+-------------------------------------+
1 row in set