-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

The MySQL Workshop
By :

Often, the table or tables you are querying have many more rows than you are interested in. Filtering is done in two ways; the first way is only selecting the columns we need. This is what we did in the previous section. The second way is to filter out the rows; this is done with a WHERE
clause in the SELECT
statement. Besides only returning the data you need, this also allows the database server to use a more efficient way of retrieving the data, which translates to faster queries.
Consider the following query:
SELECT * FROM city WHERE CountryCode='CHE';
This query will return the following results:
Figure 4.4 – The SELECT output, filtered by CountryCode CHE for Switzerland
Here, you return all columns for rows that have CHE
as CountryCode
. Every row is a city in Switzerland. Now, consider the following example:
SELECT Name, Population FROM country WHERE Continent='Oceania' AND Population > 1000000...