# TIL New SQL Operators - Except, UNION, Distinct

**Except Operator**

The `EXCEPT` operator returns distinct rows from the first (left) query that are not in the output of the second (right) query

**Eg: select \* from table1**

**except**

**select \* from table 2**

Returns all elements in table1 not present in table2

**UNION and Intersect Operator**

In case of two queries in two tables. The Union and Intersect operator does the union and intersection of two sets.

![](/files/TUWJE1CKvB3Tk8CNCJZW)

**Distinct Operator**

In case of distinct operator, it returns all the unique values corresponding to a query value we want.

`SELECT DISTINCT(status) FROM employee;`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.kurianbenoy.com/databases/til-new-sql-operators-except-union-distinct.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
