> For the complete documentation index, see [llms.txt](https://www.pranaypourkar.co.in/the-programmers-guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/sql-fundamentals/sql-operators.md).

# SQL Operators

## Description

SQL operators are symbols or keywords used to perform operations on data. They can be classified into several categories.

{% hint style="info" %}
**Clauses:** In SQL, clauses are typically complete statements within a query that define specific parts of its functionality. Examples include `SELECT`, `FROM`, `WHERE`, `JOIN`, etc. These clauses work together to form the overall query structure.

**Operators:** Operators are symbols or keywords that perform specific operations on data or expressions within a query. They typically combine values or manipulate data in some way.
{% endhint %}

## Different Operators

### **Arithmetic Operators**:

Used to perform mathematical operations.

* `+` (Addition)
* `-` (Subtraction)
* `*` (Multiplication)
* `/` (Division)
* `%` (Modulo)

**Example:**

```sql
SELECT salary + 1000 AS increased_salary FROM employees;
```

### **Comparison Operators**:

Used to compare two values.

* `=` (Equal to)
* `<>` or `!=` (Not equal to)
* `>` (Greater than)
* `<` (Less than)
* `>=` (Greater than or equal to)
* `<=` (Less than or equal to)

**Example:**

```
SELECT * FROM employees WHERE salary > 50000;
```

### **Logical Operators**:

Used to combine multiple conditions.

* `AND` (Both conditions must be true)
* `OR` (At least one condition must be true)
* `NOT` (Negates a condition)

**Example:**

```
SELECT * FROM employees WHERE salary > 50000 AND department_id = 10;
```

### **Bitwise Operators**:

Used to perform bitwise operations.

* `&` (Bitwise AND)
* `|` (Bitwise OR)
* `^` (Bitwise XOR)

**Example:**

```
SELECT 5 & 3;  -- Results in 1
```

### **Set Operators**:

Used to combine the results of two or more queries.

* `UNION` (Combines results of two queries and removes duplicates)
* `UNION ALL` (Combines results of two queries without removing duplicates)
* `INTERSECT` (Returns common results of two queries)
* `MINUS` or `EXCEPT` (Returns results from the first query that are not in the second query)

**Example:**

```
SELECT name FROM employees
UNION
SELECT name FROM managers;
```

### **String Operators**:

Used to perform operations on strings.

* `||` (Concatenation in Oracle and PostgreSQL)
* `+` (Concatenation in SQL Server)
* `LIKE` (Pattern matching)

**Example:**

```sql
SELECT first_name || ' ' || last_name AS full_name FROM employees;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://www.pranaypourkar.co.in/the-programmers-guide/database/sql-databases/sql-fundamentals/sql-operators.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.
