Chapter 9. Zeroing In on the Data You Want
In This Chapter
Specifying the tables you want to work with
Separating rows of interest from the rest
Building effective
WHERE
clausesHandling null values
Building compound expressions with logical connectives
Grouping query output by column
Putting query output in order
A database management system has two main functions: storing data and providing easy access to that data. Storing data is nothing special; a file cabinet can perform that chore. The hard part of data management is providing easy access. For data to be useful, you must be able to separate the (usually) small amount you want from the huge amount you don't want.
SQL enables you to use some characteristics of the data to determine whether a particular table row is of interest to you. The SELECT
, DELETE
, and UPDATE
statements convey to the database engine (the part of the DBMS that directly interacts with the data) which rows to select, delete, or update. You add modifying clauses to the SELECT
, DELETE
, and UPDATE
statements to refine the search to your specifications.
Modifying Clauses
The modifying clauses available in SQL are FROM
, WHERE
, HAVING
, GROUP BY
, and ORDER BY
. The FROM
clause tells the database engine which table or tables to operate on. The WHERE
and HAVING
clauses specify a data characteristic that determines whether or not to include a particular row in the current operation. The GROUP BY
and ORDER BY
clauses specify how to display the retrieved rows. Table 9-1 provides ...
Get SQL For Dummies® 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.