Description

The SQL keyword NOT is used to negate a WHERE condition, which can be used in a SELECT, UPDATE, or a DELETE statement.

SELECT With NOT

The below SQL fetches all the customers having the country not equal to "Spain".

SELECT * FROM customers
WHERE NOT country = 'Spain';

UPDATE With NOT

The below SQL updates all the customers having the country not equal to "Spain", and sets their country to "Germany";

UPDATE customers
SET country = 'Germany'
WHERE NOT country = 'Spain';

DELETE With NOT

The below SQL deletes all the customers having the country not equal to "Spain".

DELETE customers
WHERE NOT country = 'Spain';

Related Links