Guide To Writing Queries
And, Or, Not
8min
a query consists of one or multiple query terms , which are connected using the logical operators and and or 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 name name contains contains "inc" "inc" or or name name contains contains "ltd" "ltd" and and industry industry = = "banking" "banking" it will be interpreted like this name name contains contains "inc" "inc" or or ( name name contains contains "ltd" "ltd" and and industry industry = = "banking" "banking" ) this will match accounts satisfying either of the following conditions name name contains "inc" "inc" name name contains "ltd" "ltd" and and industry industry is "banking" "banking" in general, if you have something like this qt1 and and qt2 or or qt3 and and qt4 or or it will be interpreted like this qt1 and and ( qt2 or or ( qt3 and and ( qt4 or or ( ) ) ) ) it doesn't matter if you use and and or or or explicit parenthesis ( ) can be used to change this however you wish ( name name contains contains "inc" "inc" or or name name contains contains "ltd" "ltd" ) and and industry industry = = "banking" "banking" this will match accounts satisfying both of the following conditions name name contains "inc" "inc" or or "ltd" "ltd" industry industry is "banking" "banking" you can also wrap one or more query terms in not ( ) not ( ) , which negates the terms not not ( ( name name contains contains "inc" "inc" or or name name contains contains "ltd" "ltd" ) ) and and industry industry = = "banking" "banking" this will match accounts satisfying both of the following conditions name name contains neither "inc" "inc" nor "ltd" "ltd" industry industry is "banking" "banking" name name contains contains "inc" "inc" or or not ( not ( name name contains contains "ltd" "ltd" and and industry industry = = "banking" "banking" ) ) this will match accounts satisfying either of the following conditions name name contains "inc" "inc" either name name doesn't contain "ltd" "ltd" or industry industry isn't "banking" "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 fields & links docid\ kzbtllyb4xfj8df290vxi