Table of Contents
Previous Section Next Section

Chapter 2: Retrieving Data with SQL

Overview

In this chapter, you'll get started with SQL by examining how you can use SQL statements to query a relational database and extract data from it. Here, you'll be querying just one table in a database, but later on in the book (in Chapter 6, "Combining SQL Queries"), you'll see how to query data from multiple tables.

The most important SQL keyword used in querying is SELECT. This chapter introduces the basic syntax for a SQL SELECT query and demonstrates the process with some simple code examples. You'll see how to limit your queries to specific columns in a table, how to create column aliases and calculated columns, and how to sort the data returned by your query by applying an ORDER BY clause to the appropriate column.

We'll then move on to discuss how to filter your data—that is, to select or to filter out just the specific rows of data that you're interested in rather than returning every record. You can achieve this by placing various restrictions on the SQL query in a WHERE clause.

To run the code examples in this and every other chapter, you'll need to install one of the five Relational Database Management Systems (RDBMSs) covered in this book and create the InstantUniversity database, all of which is described in Appendix A, "Executing SQL Statements."


Table of Contents
Previous Section Next Section