The BOOL_OR() function calculates all the boolean values in the aggregated group, which will have these results:
- false if all the values are false for every row.
- true if at least one row in the group is true.
The input and the return type must be in BOOL.
💡NULL values are not aggregated, so it will return NULL if there are zero input rows.
In this example, we will use a payment table that stores details of the orders, whether the order has been paid or unpaid by the customer:
The above query will show the following table:
We will find out if all customers have paid for their orders using the query below:
If there is at least one TRUE value, the overall result will be TRUE. The final output shows that some order has been paid regardless of the other unpaid orders.
We will find out if Aaron has paid for his orders using the query below:
If all values are FALSE, then the overall result will be FALSE. The final output shows that Aaron hasn’t paid for all his orders.