MySQL NOT Operator

MySQL NOT Operator is one of the Logical Operators 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 Logical NOT operator in the WHERE Clause to filter the data, we are going to use the below-shown data.

Customer table 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.

SELECT NOT 1;

SELECT NOT 0;

SELECT NOT NULL;

SELECT !1;

SELECT !(1 - 1);
Example 1

NOT Example

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

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

About Suresh

Suresh is the founder of TutorialGateway and a freelance software developer. He specialized in Designing and Developing Windows and Web applications. The experience he gained in Programming and BI integration, and reporting tools translates into this blog. You can find him on Facebook or Twitter.