---
title: forall function
description: Learn the syntax of the forall function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/forall
---

# `forall` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Tests whether `func` holds for all elements in the array.

## Syntax

```
forall(expr, func)
```

## Arguments

* `expr`: An ARRAY expression.
* `func`: A lambda function returning a BOOLEAN.

## Returns

A BOOLEAN.

The lambda function uses one parameter passing an element of the array.

## Examples

```sql
> SELECT forall(array(1, 2, 3), x -> x % 2 == 0);
 false
> SELECT forall(array(2, 4, 8), x -> x % 2 == 0);
 true
> SELECT forall(array(1, NULL, 3), x -> x % 2 == 0);
 false
> SELECT forall(array(2, NULL, 8), x -> x % 2 == 0);
 NULL
```

## Related functions

* [`filter` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/filter.md)
* [`exists` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/exists.md)
