arr1 contains all the elements of arr2, that is, whether arr2 is a subset of arr1. If yes, 1 is returned. If not, 0 is returned.
Syntax
Parameters
arr: the two arrays to compare. This syntax checks whether arr2 is a subset of arr1.
The data types of elements in the two arrays must be the same. For the data types of array elements supported by the database, see ARRAY.
Return value
Returns a value of the BOOLEAN type. 1 is returned ifarr2 is a subset of arr1. Otherwise, 0 is returned.
If any of the two arrays is NULL, NULL is returned.
Usage notes
-
If an array contains
nullelements,nullis processed as a value. - An empty array is a subset of any array.
- Elements in the two arrays can have different order.
Examples
-
Create a table named
t1and insert data into this table. -
Query data from this table.
-
Check whether each row of
c2is a subset of the corresponding row ofc1.
c2 is a subset of c1 and 1 is returned.
For row 2, c2 is not a subset of c1 and 0 is returned.
For row 3, c1 is NULL and NULL is returned.
For row 4, c2 is NULL and NULL is returned.
For row 5, the two arrays contain null and null is processed as a normal value, 1 is returned.
For row 6, c2 is an empty array and considered a subset of c1. Therefore, 1 is returned.