WHERE
clause with logical operatorsWHERE [NOT] search_condition_1 {AND|OR} [NOT] search_condition_2 ...
AND
operatorWHERE categoryID = 1 AND discountPercent = 30
OR
operatorWHERE categoryID = 1 OR discountPercent = 30
NOT
operatorNOT listPrice >= 500
NOT
operatorWHERE listPrice < 500
SELECT productName, listPrice, discountPercent, dateAdded FROM products WHERE dateAdded > '2017-07-01' OR listPrice < 500 AND discountPercent > 25;
SELECT productName, listPrice, discountPercent, dateAdded FROM products WHERE (dateAdded > '2017-07-01' OR listPrice < 500) AND discountPercent > 25;
AND
and OR
logical operators to create compound conditions that consist of two or more conditions. You use the AND
operator to specify that the search must satisfy both of the conditions, and you use the OR
operator to specify that the search must satisfy at least one of the conditions.NOT
operator to negate a condition.NOT
, (2) AND
, and (3) OR
. You can use parentheses to override this order of precedence or to clarify the sequence in which the operations will be evaluated.