And, Or, Not
A query consists of one or multiple Query Terms, which are connected using the logical operators and or or.
Query Terms are grouped together in a right-associative manner. What that beauty of a sentence means is that if you write this:
It will be interpreted like this:
This will match Accounts satisfying either of the following conditions:
- name contains "inc"
- name contains "ltd" and industry is "Banking"
In general, if you have something like this:
It will be interpreted like this:
It doesn't matter if you use and or or.
Explicit parenthesis ( ) can be used to change this however you wish.
This will match Accounts satisfying both of the following conditions:
- name contains "inc" or "ltd"
- industry is "Banking"
You can also wrap one or more Query Terms in not ( ), which negates the terms:
This will match Accounts satisfying both of the following conditions:
- name contains neither "inc" nor "ltd"
- industry is "Banking"
This will match Accounts satisfying either of the following conditions:
- name contains "inc"
- either name doesn't contain "ltd" or industry isn't "Banking", or both
There are some nuances about how negations and searching fields on linked records interact with each other, which might not be immediately apparent. Check out the section on linked fields.