Skip to Content
Head First SQL, 2nd Edition
book

Head First SQL, 2nd Edition

by Kimberly Fessel
May 2026
Beginner
740 pages
17h 38m
English
O'Reilly Media, Inc.
Content preview from Head First SQL, 2nd Edition

Chapter 4. Better WHERE Clauses: Filtering Rows

Image

Here’s your opportunity to dig in. You’ve already tried out WHERE for simple table row filters, but now you can perform an in-depth exploration of WHERE to see what it can really do.

In this chapter, you’ll use AND to find rows that meet two or more requirements. You’ll switch to OR if you want rows that satisfy any of several conditions. And you will even unearth new operator artifacts to aid in your quest for missing items, ranges of values, or text patterns.

So what are you waiting for? Turn the page and let the excavation begin. WHERE is your new best friend.

Misplaced identification

Uh oh, Abby doesn’t look happy. Let’s check back in with her to see what’s going on.

Image

We can use a SELECT query with the filter:

Image

to find Abby some locations within the USA so she won’t need her passport to travel. Here’s the first few results:

Multiple row requirements

We were able to find locations within the United States, but Abby and her friend Katie wouldn’t need to fly to all of the places we found.

What if we try a SELECT query but use a filter to require plane travel?

The first few rows of those results give us:

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Head First SQL

Head First SQL

Lynn Beighley
Learning SQL

Learning SQL

Ben Forta

Publisher Resources

ISBN: 9781098163648Errata Page