Bool And
Definition
The boolAnd method allows you to add the BOOL_AND function to the query. The BOOL_AND is a function that returns the “logical AND” of all specified non-null boolean input values. That is, this function returns true if all non-null input values are true, and otherwise returns false.
There are 2 ways to call this method:
1. Calling from a KColumn or a KTableColumn
The only one method available to use this functionality calling from a KColumn or a KTableColumn is:
boolAnd(): It does not receive any parameters. TheKColumnorKTableColumnthat invokes the method will be the one supplied to theBOOL_ANDfunction.
Example
Java code:
k
.select(
APP_USER.ID.boolAnd(),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
BOOL_AND(au.id),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None
2. Calling from the KFunction class
The methods available to use this functionality calling from the KFunction class are:
boolAnd(KColumn kColumn): Receives aKColumnor aKTableColumnwhich will be supplied to theBOOL_ANDfunction.boolAnd(KCondition kCondition): Receives aKConditionwhich will be supplied to theBOOL_ANDfunction.
To use this way, you need to import the static functions as follows:
import static com.myzlab.k.KFunction.*;
Example
Java code:
k
.select(
boolAnd(APP_USER.ID),
APP_USER.CREATED_AT.cast(date())
)
.from(APP_USER)
.groupBy(APP_USER.CREATED_AT.cast(date()))
.multiple();
SQL generated:
SELECT
BOOL_AND(au.id),
CAST(au.created_at AS DATE)
FROM app_user au
GROUP BY CAST(au.created_at AS DATE)
Parameters:
- None