Finding Data: Inequality Operator

SQL: SELECT: Basics

Find all rows that a given value doesn't match a column's value.

The not equal to or inequality operator can be written in two ways != and <>. The latter is less common.

SELECT <columns> FROM <table> WHERE <column name> != <value>;
SELECT <columns> FROM <table> WHERE <column name> <> <value>;

Example:

SELECT * FROM contacts WHERE first_name != "Kenneth";
SELECT first_name, email FROM users WHERE last_name != "L:one";
SELECT name AS "Product Name" FROM products WHERE stock_count != 0;
SELECT title "Book Title" FROM books WHERE year_published != 2015;