> For the complete documentation index, see [llms.txt](https://dailyjournal.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dailyjournal.gitbook.io/notes/languages/sql/operators.md).

# Operators

## Logical Operators

<table><thead><tr><th width="143">Operators</th><th>Description</th></tr></thead><tbody><tr><td><code>LIKE</code></td><td>allows you to perform operations similar to using <strong>WHERE</strong> and <code>=</code>, but for cases when you might <strong>not</strong> know <strong>exactly</strong> what you are looking for.</td></tr><tr><td><code>IN</code></td><td>allows you to perform operations similar to using <strong>WHERE</strong> and <code>=</code>, but for more than one condition.</td></tr><tr><td><code>NOT</code> </td><td>used with <code>IN</code> and <code>LIKE</code> to select all of the rows <code>NOT LIKE</code> or <code>NOT IN</code> a certain condition.</td></tr><tr><td><code>AND</code> <strong>&#x26;</strong> <code>BETWEEN</code></td><td>allow you to combine operations where all combined conditions must be true.</td></tr><tr><td><code>OR</code> </td><td>allows you to combine operations where at least one of the combined conditions must be true.</td></tr></tbody></table>

## Set Operators

<table><thead><tr><th width="145">Operators</th><th>Description</th></tr></thead><tbody><tr><td><code>UNION</code>/<code>UNION ALL</code></td><td>combines and returns the result-set retrieved by two or more SELECT statements.</td></tr><tr><td><code>MINUS</code>/<code>EXCEPT</code></td><td>removes the duplicates from the results of the second SELECT query from the results of the first SELECT query and then returns the filtered result from the first query.</td></tr><tr><td><code>INTERSECT</code></td><td>combines the result fetched by the two SELECT statements where records from one match the other and then returns this intersection of result-sets.</td></tr></tbody></table>

Before any of the above operations are performed the following conditions should be followed

* Each SELECT statement must have the same number of columns
* The columns must also have the similar data types
* The columns in each SELECT statement should be in the same order

{% hint style="info" %}
`UNION` operation removes duplicates from the final result, whereas `UNION ALL` operation does not remove duplicates and displays all the data.
{% endhint %}

{% hint style="info" %}
**`NULL`** are different than a zero - they are cells where data does not exist. When identifying **NULL**s in a **`WHERE`** clause, we write **`IS NULL`** or **`IS NOT NULL`**. We don't use `=`, because **`NULL`** isn't considered a value in SQL. Rather, it is a property of the data.
{% endhint %}
