NOT EQUAL TO
Anonymous contributor
Published Aug 26, 2024
Contribute to Docs
In SQL, the NOT EQUAL TO
operator is used to compare two values. It returns true if the values are not equal and false if they are equal. The operator can be represented in two ways: <>
or !=
.
Syntax
-- Using the <> operator
SELECT column1, column2, ...
FROM table_name
WHERE column_name <> value;
-- Using the != operator
SELECT column1, column2, ...
FROM table_name
WHERE column_name != value;
Example
The given query will select all employees who are not in the Sales
department using the NOT EQUAL TO
operator.
SELECT *FROM employeesWHERE department <> 'Sales';
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
- Career path
Data Scientist: Machine Learning Specialist
Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.Includes 27 CoursesWith Professional CertificationBeginner Friendly95 hours - Free course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner Friendly5 hours