7
Advanced Data Filtering
In this chapter, you’ll learn how to combine WHERE
clauses to create powerful and sophisticated search conditions. You’ll also learn how to use the NOT
and IN
operators.
Combining WHERE
Clauses
All the WHERE
clauses introduced in Chapter 6, “Filtering Data,” filter data using a single criterion. For a greater degree of filter control, MySQL allows you to specify multiple WHERE
clauses. These clauses may be used in two ways: as AND
clauses or as OR
clauses.
Using the AND
Operator
To filter by more than one column, you use the AND
operator to append conditions to your WHERE
clause. The following code demonstrates this:
Input
SELECT prod_id, prod_price, prod_name
FROM products
WHERE
Get MySQL Crash Course, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.