Returns true if all elements in the array match the given condition, false otherwise. If the array contains NULL elements and all non-NULL elements match the condition, returns NULL.
array_match_all(lambda, <arr> [, <arr> ...])
lambda: A lambda expression that defines the condition to check for each element<arr>: One or more arrays to check. The lambda function will be applied to each element of these arraysReturns a nullable boolean value:
true if all elements in the array match the conditionfalse if any element in the array does not match the conditionNULL if the array contains NULL elements and all non-NULL elements match the condition-- Check if all numbers in array are greater than 5 mysql> SELECT array_match_all(x -> x > 5, [1, 2, 3, 4, 7]); +----------------------------------------------+ | array_match_all(x -> x > 5, [1, 2, 3, 4, 7]) | +----------------------------------------------+ | 0 | +----------------------------------------------+ -- Check if all numbers in array are greater than corresponding numbers in another array mysql> SELECT array_match_all((x, i) -> x > i, [1, 2, 3, 4, 5], [1, 2, 3, 4, 7]); +--------------------------------------------------------------------+ | array_match_all((x, i) -> x > i, [1, 2, 3, 4, 5], [1, 2, 3, 4, 7]) | +--------------------------------------------------------------------+ | 0 | +--------------------------------------------------------------------+
The function handles NULL values in the following way:
This function is useful for: