MySQL NOT Condition

The MySQL NOT condition is opposite of MySQL IN condition. It is used to negate a condition in a SELECT, INSERT, UPDATE or DELETE statement.

Syntax:

snippet
NOT condition

Parameter

condition: It specifies the conditions that you want to negate.

MySQL NOT Operator with IN condition

Consider a table "officers", having the following data.

MySQL NOT Condition 1

Execute the following query:

snippet
SELECT *
FROM officers
WHERE officer_name NOT IN ('Ajeet','Vimal','Deepika');

Output:

MySQL NOT Condition 2

MySQL NOT Operator with IS NULL condition:

Execute the following query:

snippet
SELECT *
FROM officers
WHERE officer_name IS NOT NULL;

Output:

MySQL NOT Condition 3

MySQL NOT Operator with LIKE condition:

We are taking the same table "officer" for this operation also:

Execute the following query:

snippet
SELECT *
FROM officers
WHERE officer_name NOT LIKE 'A%';

Output:

MySQL NOT Condition 4

MySQL NOT Operator with BETWEEN condition:

We are taking the same table "officer" for this operation also:

Execute the following query:

snippet
SELECT *
FROM officers
WHERE officer_id NOT BETWEEN 3 AND 5;

Output:

MySQL NOT Condition 5
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents