6
Filtering Data
In this chapter, you will learn how to use the SELECT
statement’s WHERE
clause to specify search conditions.
Using the WHERE
Clause
Database tables usually contain large amounts of data, and you seldom need to retrieve all the rows in a table. More often than not, you’ll want to extract a subset of a table’s data as needed for specific operations or reports. Retrieving just the data you want involves specifying search criteria, also known as filter conditions.
Within a SELECT
statement, you filter data by specifying search criteria in the WHERE
clause. You include the WHERE
clause right after the table name (the FROM
clause) as follows:
Input
SELECT prod_name, prod_price
FROM products
WHERE prod_price = 2.50;
Analysis
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.