SQL Equals To
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 tableINSERT INTO employ (employ_name, employ_id) VALUES('John', 100),('Janet', 101),('Joe', 102)# Use the EQUAL TO operator to find employees with a specific IDSELECT 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
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SQL on Codecademy
- Learn to analyze data with SQL and prepare for technical interviews.
- Includes 9 Courses
- With Certificate
- Beginner Friendly.17 hours
- Learn how to query SQL databases and design relational databases to efficiently store large quantities of data.
- Includes 5 Courses
- With Certificate
- Beginner Friendly.13 hours