Boolean functions
Boolean functions are used to perform boolean logic on different elements in Profile Query Language (PQL). More information about other PQL functions can be found in the Profile Query Language overview.
And
The and
function is used to create a logical conjunction as a boolean.
Format
{QUERY} and {QUERY}
Example
The following PQL query will return all people with home country as Canada and birth year of 1985.
homeAddress.countryISO = "CA" and person.birthYear = 1985
Or
The or
function is used to create a logical disjunction as a boolean.
Format
{QUERY} or {QUERY}
Example
The following PQL query will return all people with home country as Canada or birth year of 1985.
homeAddress.countryISO = "CA" or person.birthYear = 1985
Not
The not
(or !
) function is used to create a logical negation.
Format
not ({QUERY})
!({QUERY})
Example
The following PQL query will return all people who do not have their home country as Canada.
not (homeAddress.countryISO = "CA")
If
The if
function is used to resolve an expression depending on whether a specified condition is true as a boolean.
Format
if ({TEST_EXPRESSION}, {TRUE_EXPRESSION}, {FALSE_EXPRESSION})
{TEST_EXPRESSION}
{TRUE_EXPRESSION}
{TEST_EXPRESSION}
is true.{FALSE_EXPRESSION}
{TEST_EXPRESSION}
is false.Example
The following PQL query will set the value as 1
if the home country is Canada and 2
if the home country is not Canada.
if (homeAddress.countryISO = "CA", 1, 2)
Next steps
Now that you have learned about boolean functions, you can use them within your PQL queries. For more information about other PQL functions, please read the Profile Query Language overview.