[ Home ]

SQL 3rd cover

SQL (Third Edition)
Visual QuickStart Guide
by Chris Fehily

A newer edition is available.

Download this book’s companion files.


SQL: Visual QuickStart Guide teaches SQL — the language of databases — to beginning and intermediate programmers. With SQL, you can create, alter, and drop tables, indexes, and views; insert, update, query, and delete data; and execute transactions to maintain the integrity of your data. This book covers the relational model, the core language for ANSI/ISO (standard) SQL, and product-specific variations for Microsoft Access, Microsoft SQL Server, Oracle, IBM DB2, MySQL, and PostgreSQL. Hundreds of examples of varied difficulty encourage you to experiment and explore. Extensive cross references make this book a good quick reference for experienced programmers.

Prices and formats

   Amazon paperback (US, CA, UK, FR, DE, ES, IT, JP)

Ebook (updated edition)
   Amazon Kindle (US, CA, UK, FR, DE, ES, IT, JP, BR)
   Apple iBooks (US, CA, MX, AU, NZ, UK, IE, DE, IT, SE, NL, DK, JP, BR, more)
   Barnes & Noble Nook
   Google Play


1. DBMS Specifics
2. The Relational Model
3. SQL Basics
4. Retrieving Data From a Table
5. Operators and Functions
6. Summarizing and Grouping Data
7. Joins
8. Subqueries
9. Set Operations
10. Inserting, Updating, and Deleting Rows
11. Creating, Altering, and Dropping Tables
12. Indexes
14. Transactions
15. SQL Tricks


This book’s examples use the sample database books, described in “The Sample Database” in Chapter 2. To create books, download the zip file sql_vqs3_files.zip, expand it, and follow the instructions for your DBMS, listed below. The file readme.txt describes the distribution.

In addition to creating the tables described in “The Sample Database” in Chapter 2, the SQL scripts create additional tables used in other examples. If you’re running a DBMS locally (that is, on your own computer), then you’re the database administrator (DBA) and have all the privileges you need. If you’re connecting to a DBMS on a network server, then ask your DBA for connection parameters and the privileges to create, query, update, and drop databases and tables.

The instructions for creating the sample database explain how to use simple tools and settings. As you gain experience, you might want to switch to using the statement CREATE DATABASE to create new databases. CREATE DATABASE is a powerful but nonstandard SQL command, so its syntax and capabilities vary by DBMS; see your DBMS’s documentation. (Microsoft Access doesn’t support CREATE DATABASE, but you can create Access databases programmatically by using Visual Basic for Applications or C#.)

Errata and updates (paperback edition)

Page 264 — In the left column, the inner query should be printed in red:
SELECT outer_columns
  FROM outer_table
  WHERE outer_column_value IN
SELECT inner_column
       FROM inner_table
       WHERE inner_column = outer_column

Page 324 — Move the sentence “This statement has no effect on the target table.” from the caption for Listing 10.6 to the caption for Listing 10.7 (on page 325).