This is a read-only copy of the MariaDB Knowledgebase generated on 2024-11-15. For the latest, interactive version please visit https://mariadb.com/kb/.

JSON_ARRAY_INTERSECT

MariaDB starting with 11.2.0

JSON_ARRAY_INTERSECT was added in MariaDB 11.2.0.

Syntax

JSON_ARRAY_INTERSECT(arr1, arr2)

Description

Finds intersection between two json arrays and returns an array of items found in both array.

Examples

SET @json1= '[1,2,3]';
SET @json2= '[1,2,4]';

SELECT json_array_intersect(@json1, @json2); 
+--------------------------------------+
| json_array_intersect(@json1, @json2) |
+--------------------------------------+
| [1, 2]                               |
+--------------------------------------+
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.