Skip to main content
Log inGet a demo
Back to SQL Dictionary
Comparison operators

SQL Equal To

What is the SQL Equals To Operator?

The SQL "Equals To" operator, denoted as "=", is a fundamental operator used to compare values in a database table. It is employed in SQL queries to filter and retrieve data where a specific column's value matches a given criteria.

When you would use it

You would use the "Equals To" operator when you want to retrieve rows from a database table where a column's value matches a particular value or expression. It is commonly used in the WHERE clause of SQL SELECT statements to filter data based on equality conditions.

Syntax

The basic syntax for using the "Equals To" operator in an SQL query is as follows:

SELECT column1, column2
FROM table_name
WHERE column_name = value;
  • SELECT: Specifies the columns you want to retrieve.
  • FROM: Specifies the table from which you want to retrieve data.
  • WHERE: Specifies the condition for filtering rows.
  • column_name: The name of the column you want to compare.
  • value: The value or expression you want to compare the column with.

Parameter values

  • column_name: The name of the column you want to filter.
  • value: The value or expression you want to compare against.

Example query

Let's assume we have a table called "employees" with columns: "employee_id," "first_name," and "last_name." Here's an example query using the "Equals To" operator:

SELECT first_name, last_name
FROM employees
WHERE employee_id = 101;

In this query, we're retrieving the first name and last name of the employee whose employee_id is equal to 101.

Example table response

Assuming the "employees" table has the following data:

employee_idfirst_namelast_name
101JohnSmith
102JaneDoe
103AliceJohnson

The query would return:

first_namelast_name
JohnSmith

Use cases

The "Equals To" operator is commonly used in various scenarios, including:

  1. Retrieving specific records by a unique identifier.
  2. Filtering data based on exact matches, such as searching for customers with a specific email address.
  3. Comparing values in related tables to perform JOIN operations.

SQL languages this is available for

The "Equals To" operator is a fundamental feature supported by all major SQL database management systems (DBMS) and SQL-based languages, including but not limited to:

  • MySQL
  • PostgreSQL
  • Oracle Database
  • Microsoft SQL Server
  • SQLite
  • IBM Db2

In summary, the "Equals To" operator is a powerful tool for filtering and retrieving data from SQL databases, available in virtually all SQL database systems. It's an essential component of SQL queries, allowing you to specify precise conditions for data retrieval.

Related

SQL Comments

SQL Not Equal To

SQL Greater Than

Ready to put your SQL knowledge to work?

Practice writing SQL to call data from the warehouse and sync it into Google Sheets in this 5 minute interactive demo.

Hightouch Audiences user interface.

Activate your data in less than 5 minutes