NOT EQUAL TO

Anonymous contributor's avatar
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 employees
WHERE department <> 'Sales';

All contributors

Contribute to Docs

Learn SQL on Codecademy