Get Common Items In Arrays | ARRAY_INTERSECTION

Syntax

ARRAY_INTERSECTION( [...values] )

Parameters

values
Any number of ARRAYS the intersection will be computed from.

Return Value

An ARRAY containing all the items that are present in all of the VALUES.

Description

Gets the values that exist in all provided ARRAY values. Equality of ARRAY and MAP values are performed structurally as is done with the EQUAL operation.

Examples

ARRAY_INTERSECTION([1, 2, 3]) # returns [1, 2, 3]
ARRAY_INTERSECTION() # returns []
ARRAY_INTERSECTION([1, 2, 3], [2, 3, 4]) # returns [2, 3]
ARRAY_INTERSECTION([[1, 2], [3, 4]], [[1, 2], [4, 5]]) # returns [[1, 2]]
ARRAY_INTERSECTION([1, 2], [2, 3], [1, 4], [4, 5], [7]) # returns []