Database Reference
In-Depth Information
6
Filtering Data
In this chapter, you 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 want to extract a
subset of the table's data as needed for specific operations or reports. Retrieving
just the data you want involves specifying search criteria , also known as a filter
condition .
Within a SELECT statement, data is filtered by specifying search criteria in the
WHERE clause. The WHERE clause is specified right after the table name (the
FROM clause) as follows:
Input
SELECT prod_name, prod_price
FROM products
WHERE prod_price = 2.50;
Analysis
This statement retrieves two columns from the products table, but instead of
returning all rows, only rows with a prod_price value of 2.50 are returned,
as follows:
Output
+---------------+------------+
| prod_name | prod_price |
+---------------+------------+
| Carrots | 2.50 |
| TNT (1 stick) | 2.50 |
+---------------+------------+
 
 
 
Search WWH ::




Custom Search