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:
NOT condition
condition: It specifies the conditions that you want to negate.
Consider a table "officers", having the following data.
Execute the following query:
SELECT * FROM officers WHERE officer_name NOT IN ('Ajeet','Vimal','Deepika');
Output:
Execute the following query:
SELECT * FROM officers WHERE officer_name IS NOT NULL;
Output:
We are taking the same table "officer" for this operation also:
Execute the following query:
SELECT * FROM officers WHERE officer_name NOT LIKE 'A%';
Output:
We are taking the same table "officer" for this operation also:
Execute the following query:
SELECT * FROM officers WHERE officer_id NOT BETWEEN 3 AND 5;
Output: