MySQL NOT Operator

MySQL NOT Operator is one of the Logical Operator which is useful in the WHERE Clause to apply filters on the rows returned by SELECT Statement. This operator returns the result as:

  • 1, if the operand is zero
  • 0, if the operand is 1.
  • NULL, If the operand is NULL.

To explain the MySQL Logical NOT operator in WHERE Clause to filter the data, we are going to use the below-shown data.

MySQL NOT Operator 0

MySQL NOT Operator Command prompt

In this MySQL example, we pass Zeros, Ones, and Null values with a different combination. This example helps you to understand the Truth table behind the NOT Operator.

-- NOT Operator in MySQL Example

SELECT NOT 1;

SELECT NOT 0;

SELECT NOT NULL;

SELECT !1;

SELECT !(1 - 1);
MySQL NOT Operator Example 1

MySQL NOT Example

The NOT Operator is used to test user specified condition in WHERE Clause against the SELECT Statement records.

-- MySQL NOT Operator Example
USE company;
SELECT CustID,
		First_Name, Last_Name,
        Education, Profession,
        Yearly_Income, Sales
FROM customers
WHERE Education != 'High School';
MySQL NOT Operator Example 2