ePUB is an open, industry-standard format for eBooks. However, support of ePUB and its many features varies across reading devices and applications. Use your device or app settings to customize the presentation to your liking. Settings that you can customize often include font, font size, single or double column, landscape or portrait mode, and figures that you can click or tap to enlarge. For additional information about the settings and features on your reading device or app, visit the device manufacturers Web site.
Many titles include programming code or configuration examples. To optimize the presentation of these elements, view the eBook in single-column, landscape mode and adjust the font size to the smallest setting. In addition to presenting code and configurations in the reflowable text format, we have included images of the code that mimic the presentation found in the print book; therefore, where the reflowable format may compromise the presentation of the code listing, you will see a Click here to view code image link. Click the link to view the print-fidelity code image. To return to the previous page viewed, click the Back button on your device or app.
The Language
of SQL
Third Edition
Larry Rockoff
Boston Columbus New York San Francisco Amsterdam Cape Town
Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City
So Paulo Sydney Hong Kong Seoul Singapore Taipei Tokyo
The Language of SQL, Third Edition
Copyright 2022 by Pearson Education, Inc.
All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the information contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Nor is any liability assumed for damages resulting from the use of the information contained herein.
ISBN-13: 978-0-13-763269-5
ISBN-10: 0-13-763269-X
Library of Congress Control Number: 2021947847
ScoutAutomatedPrintCode
Trademarks
All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. The publisher cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark.
Warning and Disclaimer
Every effort has been made to make this book as complete and as accurate as possible, but no warranty or fitness is implied. The information provided is on an as is basis. The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book.
Special Sales
For information about buying this title in bulk quantities, or for special sales opportunities (which may include electronic versions; custom cover designs; and content particular to your business, training goals, marketing focus, or branding interests), please contact our corporate sales department at or (800) 382-3419.
For government sales inquiries, please contact .
For questions about sales outside the U.S., please contact .
Editor-in-Chief
Mark Taub
Acquisitions Editors
Kim Spenceley, Chelsea Noack
Development Editor
Chris Zahn
Managing Editor
Sandra Schroeder
Senior Project Editor
Tracey Croom
Project and Copy Editor
Dan Foster
Indexer
Valerie Haynes Perry
Proofreader
Scout Festa
Technical Reviewer
Julien Kervizic
Cover Designer
Chuti Prasertsith
Compositor
Danielle Foster
Table of Contents
About the Author
Larry Rockoff has been involved with SQL and business intelligence development for many years. His main area of interest is in using reporting tools to explore and analyze data in complex databases. He holds an MBA from the University of Chicago and a BFA from the University of Illinois.
In addition to writing about SQL, he has also published books on Microsoft Excel and Access. His latest editions of those texts are Exploring Data with Excel 2019 and Exploring Data with Access 2019.
He also maintains a website that features book reviews on technology topics, as well as broader issues regarding technology and society:
larryrockoff.com
Please feel free to visit that site to contact the author with any comments or questions.
Acknowledgments
A huge thanks goes out to all at Pearson who assisted with this book. Id like to thank Kim Spencer, who encouraged me to write a third edition, and Chelsea Noack, who oversaw and guided me through the project, as well as the editors at Pearson who assisted with this project, Tracey Croom, Chris Zahn, and Sandra Schroeder. Id also like to thank project editor and copy editor Dan Foster, who added some grace to my sentences, as well as Julien Kervizic, who did a superb job on the technical review. As with the second edition, Chuti Prasertsith provided a wonderfully vibrant cover design. Finally, I must mention the generally thankless tasks of the books indexer, Valerie Haynes Perry; proofreader, Scout Festa; and compositor, Danielle Foster.
As this is a third edition, Id also like to thank all readers of the first and second editions, and especially those individuals who have contacted me at larryrockoff.com and offered gracious comments as to the usefulness of the book in their personal lives. Its both humbling and thrilling to realize that ones words and musings on a relatively mundane topic can assist someone halfway around the world.
Introduction
Structured Query Language (SQL) is the primary language used to communicate with relational databases. The goal of this book is to serve as a useful introductory guide to this essential language.
In an alternate universe, the title of this book might have been The Logic of SQL. This is because, like all computer languages, the language of SQL has much more to do with cold hard logic than with English vocabulary. Nevertheless, the word language has been retained in the title for several reasons. First, a certain language-based syntax in SQL distinguishes it from other computer languages. Unlike other languages, SQL employs many ordinary words, such as WHERE and FROM, as keywords in its syntax.
In the spirit of the language embedded in SQL, weve adopted an emphasis on language in our sequence of topics. With this book, youll learn SQL as you would learn English. SQL keywords are presented in a logical progression, from simple to more complex. In essence, this is an attempt to deal with language and logic simultaneously.
To learn any language, one must begin by hearing and remembering the words that form the basis of its utterance. At the same time, those words have a certain meaning that must be understood. In the case of SQL, the meaning has a great deal to do with logic.