ARRAY_CONTAINS
Description
The ARRAY_CONTAINS function is used to determine whether an array contains a specified value. When the specified value exists in the array, the function returns true; otherwise, it returns false.
Parameter Description
- array:
array<T>
, represents the array to be searched. - value: T type, represents the value of the element to be found.
Return Type
- Returns a boolean value. When the array contains the specified value, it returns true; otherwise, it returns false.
Example
- Determine whether the array contains a specific element:
- Using the ARRAY_CONTAINS function in actual queries:
The above query will return student records that contain the interest 'Basketball' in the interests array.
- Multiple condition judgment:
The above query will return product records that contain both 'Bluetooth' and 'Waterproof' features in the features array.
By using the ARRAY_CONTAINS function, you can easily implement the judgment and filtering of array elements in SQL queries, thereby obtaining the required data more accurately.