Refining What You See Using WHERE

The type of SELECT statement we’ve worked with so far retrieves all the rows from a given table and uses them in the statement’s result set. This is great if you really do need to see all the information the table contains. But what if you want to find only the rows that apply to a specific person, a specific place, a particular numeric value, or a range of dates? These are not unusual requests. In fact, they are the impetus behind many of the questions you commonly pose to the database. You might, for example, have a need to ask the following types of questions.

“Who are our customers in Seattle?”

“Show me a current list of our Bellevue employees and their phone numbers.”

“What kind of music classes do we ...

Get SQL Queries for Mere Mortals: A Hands-On Guide to Data Manipulation in SQL, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.