And, Or, Not
8 min
a query consists of one or multiple query terms , which are connected using the logical operators \<font color="#9900ef">and\</font> or \<font color="#9900ef">or\</font> query terms are grouped together in a right associative manner what that beauty of a sentence means is that if you write this \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"ltd"\</font> \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> \<font color="#9900ef">=\</font> \<font color="#3b9f0f">"banking"\</font> it will be interpreted like this \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> ( \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"ltd"\</font> \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> \<font color="#9900ef">=\</font> \<font color="#3b9f0f">"banking"\</font> \<font color="#3b9f0f"> \</font> ) this will match accounts satisfying either of the following conditions \<font color="#fcb900">name\</font> contains \<font color="#3b9f0f">"inc"\</font> \<font color="#fcb900">name\</font> contains \<font color="#3b9f0f">"ltd"\</font> \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> is \<font color="#3b9f0f">"banking"\</font> in general, if you have something like this qt1 \<font color="#9900ef">and\</font> qt2 \<font color="#9900ef">or\</font> qt3 \<font color="#9900ef">and\</font> qt4 \<font color="#9900ef">or \</font> it will be interpreted like this qt1 \<font color="#9900ef">and\</font> ( qt2 \<font color="#9900ef">or\</font> ( qt3 \<font color="#9900ef">and\</font> ( qt4 \<font color="#9900ef">or\</font> ( ) ) ) ) it doesn't matter if you use \<font color="#9900ef">and\</font> or \<font color="#9900ef">or\</font> explicit parenthesis ( ) can be used to change this however you wish ( \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"ltd" \</font> ) \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> \<font color="#9900ef">=\</font> \<font color="#3b9f0f">"banking"\</font> this will match accounts satisfying both of the following conditions \<font color="#fcb900">name\</font> contains \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> \<font color="#3b9f0f">"ltd"\</font> \<font color="#fcb900">industry\</font> is \<font color="#3b9f0f">"banking"\</font> you can also wrap one or more query terms in \<font color="#9900ef">not ( )\</font> , which negates the terms \<font color="#9900ef">not\</font> \<font color="#9900ef">(\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"ltd" \</font> \<font color="#9900ef">)\</font> \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> \<font color="#9900ef">=\</font> \<font color="#3b9f0f">"banking"\</font> this will match accounts satisfying both of the following conditions \<font color="#fcb900">name\</font> contains neither \<font color="#3b9f0f">"inc"\</font> nor \<font color="#3b9f0f">"ltd"\</font> \<font color="#fcb900">industry\</font> is \<font color="#3b9f0f">"banking"\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"inc"\</font> \<font color="#9900ef">or\</font> \<font color="#9900ef">not (\</font> \<font color="#fcb900">name\</font> \<font color="#9900ef">contains\</font> \<font color="#3b9f0f">"ltd"\</font> \<font color="#9900ef">and\</font> \<font color="#fcb900">industry\</font> \<font color="#9900ef">=\</font> \<font color="#3b9f0f">"banking" \</font> \<font color="#9900ef">)\</font> this will match accounts satisfying either of the following conditions \<font color="#fcb900">name\</font> contains \<font color="#3b9f0f">"inc"\</font> either \<font color="#fcb900">name\</font> doesn't contain \<font color="#3b9f0f">"ltd"\</font> or \<font color="#fcb900">industry\</font> isn't \<font color="#3b9f0f">"banking"\</font> , 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 docid\ kzbtllyb4xfj8df290vxi