13.11 JSON_TRANSFORM Operator MINUS
JSON_TRANSFORM
operator MINUS
removes
array elements that are in a given set of values. This is a set-difference
operation.
It removes all elements of the array that's targeted by the LHS path expression that are equal to any of the values specified by the RHS. The RHS path expression can match a single value or multiple values.
Note: This is a set operation; the order of all array elements is undefined after the operation.
Example 13-20 JSON_TRANSFORM: Set Difference Of Two Arrays As Sets
Array a
in the resulting object is the set-difference of input
arrays $.a
and $.b
.
Array b
in the resulting object is unchanged.
SELECT json_transform('{"a":[ 1, 2, 3, 4 ], "b":[ 2, 5 ]}',
MINUS '$.a' = PATH '$.b[*]')
Result:
{"a":[ 1, 4, 3 ], "b":[ 2, 5 ]}
These are the handlers allowed for operator MINUS
:
-
ERROR ON MISSING
(default),IGNORE ON MISSING
,CREATE ON MISSING
,NULL ON MISSING
. -
ERROR ON MISMATCH
(default). -
NULL ON NULL
(default),IGNORE ON NULL
,ERROR ON NULL
.