Purpose
You can call this function to verify whether a value exists in a JSON array. It returns 1 if the retrieved value exists in the specified JSON array. Otherwise, it returns 0.
Syntax
value MEMBER OF(json_array)
Notes
If value is an element of json_array, this function returns 1. Otherwise, it returns 0.
value must be a scalar or JSON document. If it is a scalar, the operator treats it as an element of a JSON array.
Examples
obclient> SELECT 45 MEMBER OF('[123, "abc", 45, "ab", 10]');
+--------------------------------------------+
45 MEMBER OF('[123, "abc", 45, "ab", 10]')
+--------------------------------------------+
1
+--------------------------------------------+
1 row in set
obclient> SELECT 'cd' MEMBER OF('[23, "abc", 17, "cd", 10]');
+---------------------------------------------+
'cd' MEMBER OF('[23, "abc", 17, "cd", 10]')
+---------------------------------------------+
1
+---------------------------------------------+
1 row in set
obclient> SELECT 5 MEMBER OF('[123, "abc", 45, "ab", 10]');
+-------------------------------------------+
5 MEMBER OF('[123, "abc", 45, "ab", 10]')
+-------------------------------------------+
0
+-------------------------------------------+
1 row in set
obclient> SELECT
45 MEMBER OF('[23, "abc", "45", "ab", 10]'),
"45" MEMBER OF('[23, "abc", 45, "ab", 10]')\G
*************************** 1. row ***************************
45 MEMBER OF('[23, "abc", "45", "ab", 10]'): 0
"45" MEMBER OF('[23, "abc", 45, "ab", 10]'): 0
1 row in set
obclient> SELECT CAST('[4,5]' AS JSON) MEMBER OF('[[3,2],[4,5]]');
+--------------------------------------------------+
CAST('[4,5]' AS JSON) MEMBER OF('[[3,2],[4,5]]')
+--------------------------------------------------+
1
+--------------------------------------------------+
1 row in set
obclient> SELECT JSON_ARRAY(4,5) MEMBER OF('[[3,2],[4,5]]');
+--------------------------------------------+
JSON_ARRAY(4,5) MEMBER OF('[[3,2],[4,5]]')
+--------------------------------------------+
1
+--------------------------------------------+
1 row in set