Combining Conditions and Boolean Operators Exercise Answers
Exercise #1
SELECT customerid, order_date, item
FROM items_ordered
WHERE (item <> 'Snow shoes') AND (item <> 'Ear muffs');
Note: Yes, that is correct, you do want to use an AND here. If you were to use
an OR here, then either side of the OR will be true, and EVERY row will be
displayed. For example, when it encounters 'Ear muffs', it will evaluate to
True since 'Ear muffs' are not equal to 'Snow shoes'.
Exercise #2
SELECT item, price
FROM items_ordered
WHERE (item LIKE 'S%') OR (item LIKE 'P%') OR (item LIKE 'F%');
|