For the complete documentation index, see llms.txt. This page is also available as Markdown.

SQL Operators

Description

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

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.

Different Operators

Arithmetic Operators:

Used to perform mathematical operations.

  • + (Addition)

  • - (Subtraction)

  • * (Multiplication)

  • / (Division)

  • % (Modulo)

Example:

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:

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:

Bitwise Operators:

Used to perform bitwise operations.

  • & (Bitwise AND)

  • | (Bitwise OR)

  • ^ (Bitwise XOR)

Example:

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:

String Operators:

Used to perform operations on strings.

  • || (Concatenation in Oracle and PostgreSQL)

  • + (Concatenation in SQL Server)

  • LIKE (Pattern matching)

Example:

Last updated