-> "17" MEMBER OF(’[23, "abc", 17, "ab", 10]’)\G *************************** 1. row *************************** 17 MEMBER OF(’[23, "abc", "17", "ab", 10]’): 0 "17" MEMBER OF(’[23, "abc", 17, "ab", 10]’): 0 1 row in set (0.00 sec) 

To use this operator with a value which itself an array, it is necessary to cast it explicitly as a JSON array. You can do this with CAST(... AS JSON) : 

mysql> SELECT CAST(’[4,5]’ AS JSON) MEMBER OF(’[[3,4],[4,5]]’); +--------------------------------------------------+ | CAST(’[4,5]’ AS JSON) MEMBER OF(’[[3,4],[4,5]]’) | +--------------------------------------------------+ | 1 | +--------------------------------------------------+ 1 row in set (0.00 sec) 

It is also possible to perform the necessary cast using the JSON_ARRAY()  function, like this: 

mysql> SELECT JSON_ARRAY(4,5) MEMBER OF(’[[3,4],[4,5]]’); +--------------------------------------------+ | JSON_ARRAY(4,5) MEMBER OF(’[[3,4],[4,5]]’) | +--------------------------------------------+ | 1 | +--------------------------------------------+ 1 row in set (0.00 sec) 

Any JSON objects used as values to be tested or which appear in the target array must be coerced to the correct type using CAST(... AS JSON)  or JSON_OBJECT() . In addition, a target array containing JSON objects must itself be cast using JSON_ARRAY . This is demonstrated in the following sequence of statements: 

## 12.18.4 Functions That Modify JSON Values 

mysql> SET @a = CAST(’{"a":1}’ AS JSON); Query OK, 0 rows affected (0.00 sec) mysql> SET @b = JSON_OBJECT("b", 2); Query OK, 0 rows affected (0.00 sec) mysql> SET @c = JSON_ARRAY(17, @b, "abc", @a, 23); Query OK, 0 rows affected (0.00 sec) mysql> SELECT @a MEMBER OF(@c), @b MEMBER OF(@c); +------------------+------------------+ | @a MEMBER OF(@c) | @b MEMBER OF(@c) | +------------------+------------------+ | 1 | 1 | +------------------+------------------+ 1 row in set (0.00 sec) 

The MEMBER OF()  operator was added in MySQL 8.0.17. 

The functions in this section modify JSON values and return the result. 

• JSON_ARRAY_APPEND( json_doc , path , val [, path , val ] ...) 

Appends values to the end of the indicated arrays within a JSON document and returns the result. Returns NULL  if any argument is NULL . An error occurs if the json_doc  argument is not a valid JSON document or any path  argument is not a valid path expression or contains a *  or **  wildcard. 

The path-value pairs are evaluated left to right. The document produced by evaluating one pair becomes the new value against which the next pair is evaluated. 

