Control which rows are retrieved

Question

How can you produce a list of facilities that charge a fee to members?

Expected Results

facidnamemembercostguestcostinitialoutlaymonthlymaintenance
0Tennis Court 152510000200
1Tennis Court 25258000200
4Massage Room 1358040003000
5Massage Room 2358040003000
6Squash Court3.517.5500080

Your Answer

Your Results

Loading database...

Answers and Discussion

select * from cd.facilities where membercost > 0;

The FROM clause is used to build up a set of candidate rows to read results from. In our examples so far, this set of rows has simply been the contents of a table. In future we will explore joining, which allows us to create much more interesting candidates.

Once we've built up our set of candidate rows, the WHERE clause allows us to filter for the rows we're interested in - in this case, those with a membercost of more than zero. As you will see in later exercises, WHERE clauses can have multiple components combined with boolean logic - it's possible to, for instance, search for facilities with a cost greater than 0 and less than 10. The filtering action of the WHERE clause on the facilities table is illustrated below: