Chapter 4. Retrieving Data From a Table

This chapter introduces SQL’s workhorse—the SELECT statement. Most SQL work involves retrieving and manipulating data by using this one (albeit complex) statement. SELECT retrieves rows, columns, and derived values from one or more tables in a database; its syntax is:

SELECT columns
  FROM tables
  [JOIN joins]
  [WHERE search_condition]
  [GROUP BY grouping_columns]
  [HAVING search_condition]
  [ORDER BY sort_columns];

As each clause has a specific use, I’ll cover the clauses individually: SELECT, FROM, ORDER BY, and WHERE in this chapter, GROUP BY and HAVING in Chapter 6, and JOIN in Chapter 7. (Recall that italic type denotes replaceable identifiers and expressions, and brackets indicate an optional clause; ...

Get SQL: Visual QuickStart Guide 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.