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];
SELECT
, FROM
, ORDER BY
, and WHERE
are covered in this chapter, GROUP BY
and HAVING
in Chapter 6, and JOIN
in Chapter 7. By convention, I call only a SELECT
statement a query because it returns a result set. DBMS documentation and other books might refer to any SQL statement as a query. Although SELECT ...
Get SQL: Visual QuickStart Guide, Third Edition 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.