SQL AND, OR, NOT Logical Operators. The following SQL commands show how to user AND operator, OR Operator, NOT Operator on SQL Where Clone for making condition.
AND Operator Syntax:
SELECT col1, co2, ...
FROM table_name
WHERE condition1 AND condition2 AND condition3;
Example:
SELECT * FROM employees
WHERE country='UK' AND city='London';
SQL OR Operator Syntax:
SELECT column, column, ...
FROM table_name
WHERE condition OR condition OR condition;
Example:
SELECT * FROM employees
WHERE city='London’' OR city='Toronto';
SQL NOT Operator Syntax:
SELECT column, column, ...
FROM table_name
WHERE NOT condition;
Example:
SELECT * FROM employees
WHERE NOT country='Germany';
Combining AND, OR and NOT:
SELECT * FROM employees
WHERE country='USA' AND (city='Columbus' OR city=’Chicago');
SELECT * FROM employees
WHERE NOT country='Germany'
AND NOT country='USA';`