Equals To

Anonymous contributor's avatar
Anonymous contributor
Anonymous contributor's avatar
Anonymous contributor
Published Aug 29, 2024
Contribute to Docs

The EQUAL TO operator is used to compare the equality of two expressions, used with the WHERE clause.

Syntax

SELECT column1, column2, ...
FROM table_name
WHERE column1 = condition;

The equal to operator = can be combined with other comparison operators to check for the following:

  • >=: Greater than or equal to
  • <=: Less than or equal to
  • !=: Not equal

Example

Return employees that have employee IDs equal to 100 in the table Employ:

# Create a table named 'employ'
CREATE TABLE employ (employ_name VARCHAR(30), employ_id INT PRIMARY KEY);
# Insert some stocks into the table
INSERT INTO employ (employ_name, employ_id) VALUES
('John', 100),
('Janet', 101),
('Joe', 102)
# Use the EQUAL TO operator to find employees with a specific ID
SELECT employ_name, employ_id FROM employ WHERE employ_id = '100';

The query results with the following result:

employ_name, employ_id
'John', 100

All contributors

Contribute to Docs

Learn SQL on Codecademy