---
title: And, Or, Not
slug: and-or-not
createdAt: 2023-03-19T15:55:54.000Z
---

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>.&#x20;

![](https://api.archbee.com/api/optimize/fRibh2_2NwaS_4MGgrZuA/EFGucd1FYBfUxrK-LQqlp_queryterms.png)

Query Terms are **grouped together in a right-associative manner**. What that beauty of a sentence means is that if you write this:

:::BlockQuote
<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:

:::BlockQuote
<font color="#fcb900">**name**</font> <font color="#9900ef">**contains**</font> <font color="#3b9f0f">**"inc"**</font> <font color="#9900ef">**or**</font>**&#x20;(&#x20;**<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>

***

::::hint{type="info"}
*In general, if you have something like this:*



:::BlockQuote
**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:*



:::BlockQuote
**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&#x20;*<font color="#9900ef">***and***</font>*&#x20;or&#x20;*<font color="#9900ef">***or***</font>.
::::

***

Explicit parenthesis **`( )`** can be used to change this however you wish.

:::BlockQuote
**(&#x20;**<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>**)&#x20;**<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:&#x20;

- <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&#x20;**&#x74;he terms:

:::BlockQuote
<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>

:::BlockQuote
****<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

***

:::hint{type="warning"}
*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&#x20;*[linked fields](docId\:kzBTLLYb4xfJ8DF290vXI)*.*
:::

