CHAPTER 10 Thinking in SQL

“It ain’t so much the things we don’t know that get us into trouble. It’s theThing we know that just ain’t so.”

—Artemus Ward (Charles Farrar Browne),American humorist (1834–1867)

THE BIGGEST HURDLE in learning SQL is thinking in sets and logic, instead of in sequences and processes. I just gave you a list of heuristics in the previous chapter, but let’s take a little time to analyze why mistakes were made. You now have some theory, but can you do diagnostics?

I tried to find common errors that new programmers make, but perhaps the most difficult thing to learn is thinking in sets. Consider the classic puzzle shown in Figure 10.1.

Figure 10.1 Classic block puzzle.

The usual mistake people make is trying to count ...

Get Joe Celko's SQL Programming Style now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.