JSON_ARRAY_INTERSECT was added in MariaDB 11.2.0.
JSON_ARRAY_INTERSECT(arr1, arr2) :
Goes over one of the json and adds each item of the array in hash (after normalizing each item). Go over the second array, searching the normalized item one by one in the hash. If the item is found, adds it to the result.
SET @json1= '[1,2,3]'; SET @json2= '[1,2,4]'; SELECT json_array_intersect(@json1, @json2); +--------------------------------------+ | json_array_intersect(@json1, @json2) | +--------------------------------------+ | [1, 2] | +--------------------------------------+
© 2023 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/json_array_intersect/