What's the difference between a "nested/sub query" and an "additional query"?
In this article:
- What is a nested/sub query in a search?
- What is an additional query in a search?
- What is the difference between them?
- Common example where a nested query should be used
What is a nested/sub query in a search?
Below is an example of a nested/sub query. To add this, click Advanced options > Add nested/sub query.
NOTE: There are no search criteria being shown. The nested/sub query is boxed in red.
What is an additional query in a search?
Below is an example of an additional query. To add this, click Advanced options > Add additional query.
NOTE: There are no specific search criteria being shown. The additional query is boxed in red.
What is the difference between them?
Nested queries allow you to search for:
(this or that) AND the other
In the above search, “that” would be a nested query, and you would get results that match either "this" or "that". That combined result set is then restricted by any data matching “other”.
If instead you were to search without nesting, using additional queries:
this OR that AND the other
...where all search criteria are in the same query, the results would be unreliable because “or that” would not be restricted by "the other".
For this reason, we recommend using nested queries when you want to evaluate results together, in combination with another query.
Common example where a nested query should be used
In this example, the query “Anyone who is a current parent” should be nested.
Example
Anyone who donated last year
OR
Anyone who is a current parent
AND NOT
Anyone who has donated this year