bool_and()

A function returning true or false depending on whether all non-NULL input values are true

bool_and() is a system function which returns true if all non-NULL input values are true, otherwise false.

bool_and() was added in PostgreSQL 8.0.

Usage

bool_and ( boolean ) → boolean

bool_and()is equivalen to the SQL standard every().

Change history

Examples

postgres=# CREATE TABLE booltest (val bool);
CREATE TABLE

postgres=# INSERT INTO booltest VALUES (TRUE);
INSERT 0 1

postgres=# SELECT bool_and(val) FROM booltest;
 bool_and 
----------
 t
(1 row)

postgres=# INSERT INTO booltest values (FALSE);
INSERT 0 1

postgres=# SELECT bool_and(val) FROM booltest;
 bool_and 
----------
 f
(1 row)

Categories

System function

See also

bool_or()