O'Reilly logo

Getting Started with SQL by Thomas Nield

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required


Nobody needs to learn how a car engine works in order to drive a car. The whole point of technologies like SQL is to allow you to focus on the business problem, and not worry about how the technical details are executed. This book will give you a practical focus on using SQL, and will steer away from unnecessary technical details that are likely not pertinent to your immediate needs. Much of the content revolves around hands-on exercises with real databases you can download so you see how concepts are applied. When you finish this book you will have practical knowledge to work with databases, as well as use them to overcome your business challenges.

How to Use This Book

This book is designed to teach the fundamentals of SQL and working with databases. Readers who have experience using Excel spreadsheets should find this material accessible but still challenging. Individuals who have not worked with Excel may be more challenged. It is helpful to be familiar with concepts used in Excel, such as rows, columns, tables, mathematical expressions (e.g., Excel formulas), and aggregate calculations (e.g., SUM, AVG, MIN, MAX, COUNT). These concepts will still be taught here, but some practical Excel experience will help expedite understanding.

Basic computer literacy is required, and readers should know how to navigate folders and copy/paste files, as well as download and save files from the Web.

As you go through the material, have a computer on hand to practice the examples. While some people can learn by just reading, it is best to practice the material at some point to reinforce the knowledge.

Proficiency comes through repeated use and practice. In your job, it is likely that you will use some SQL functionalities heavily and others not as much. That is OK. It is more important to become proficient in what your job requires, and consult this book (or Google) as a reference when you need answers about an unfamiliar topic.

When working with technology, you are never expected to know everything. As a matter of fact, technology topics are so vast in number it would be impossible. So it is helpful to develop a degree of tunnel vision and learn only enough to fulfill the task at hand. Otherwise, you can get overwhelmed or distracted learning irrelevant topics. Hopefully this book will give you a foundation of knowledge, and afterward you can continue to learn about topics that are pertinent to you.

You are always welcome to reach out to me at tmnield@outlook.com, and I will answer any questions to the best of my ability. If you have questions about positioning your career with technical skillsets or have a SQL question, I might be able to help. I hope that this material not only augments your skillset and career opportunities, but also sparks new interests that excite you like it did for me.

Conventions Used in This Book

The following typographical conventions are used in this book:


Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.


This element signifies a general note.

Using Code Examples

Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/thomasnield/oreilly_getting_started_with_sql.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Getting Started with SQL by Thomas Nield (O’Reilly). Copyright 2016 Thomas Nield, 978-1-4919-3861-4.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

Safari® Books Online


Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of plans and pricing for enterprise, government, education, and individuals.

Members have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and hundreds more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://bit.ly/getting-started-with-sql.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia


I am blessed to have amazing people surrounding me, and I realize how central they have been in my life and everything I do. If it was not for them, this book would probably not have happened.

First and foremost, I would like to thank my mom and dad. They have given everything to secure my future. I know for a fact that I would not have the opportunities I have today if it was not for them. My dad worked hard to provide a better education for my brothers and me, and my mother always pushed me forward, even when I resisted. She taught me to never settle and always struggle through my limits.

I cannot express enough gratitude toward my leaders, managers, and colleagues at Southwest Airlines Revenue Management. Justin Jones and Timothy Keeney have a warrior spirit and zeal for innovation that few possess. They truly define the leadership and spirit of Southwest Airlines, but more importantly they are good guys. They will always be my friends and they’ve made it hard to imagine a life without Southwest Airlines.

Robert Haun, Brice Taylor, and Allison Russell continuously work to make our team the forefront of innovation and continuously pursue new ideas, and I am blessed to work in the environment they have helped create. I also have to thank Matt Louis for bringing me on board at Revenue Management, and Steven Barsalou who made me realize how little I really knew about SQL. Steven is the first person who came to mind when I needed a reviewer for this book, and I am grateful he came on board this project.

Then there is the project team I work with every day: Brian Denholm, Paul Zigler, Bridget Green, Todd Randolph, and Chris Solomon. As a team, the feats we pull off never cease to amaze me. Brian is the kind of project manager that can effectively bridge technology and business jargon together, and he will not hesitate to get his hands dirty with SQL and the occasional code review. I want to give a special thanks to Chris Solomon for helping me with everything I do every day. He not only has a rare talent to absorb high volumes of technical knowledge and maintain it in a business perspective, but he is also a nice guy that I am privileged to be friends with. Chris is always a key player in any project, and I was thrilled when he agreed to review this book.

I cannot forget the great people who worked at Southwest Airlines Ground Ops Safety Regulatory Compliance, including Marc Stank, Reuben Miller, Mary Noel Hennes, and everybody else I had the privilege of working with. I interned and contracted with that department a few years back and some of my fondest memories are there. It was there I discovered my passion for technology, and they provided many opportunities for me to pursue that, whether it was throwing together databases or prototyping an iPad app.

When I announced I was publishing this book I did not expect Richard Hipp, the founder and creator of SQLite, to reach out to me. Richard graciously stepped up to be the technical reviewer for this book and it has been a tremendous honor to have him on board. The technology community continues to amaze me, and the fact Richard Hipp joined this project shows how unique and close-knit the community really is.

Shannon Cutt has been my editor at O’Reilly for this book. This is my first book and I was uncertain what the publishing experience would be like. But Shannon made publishing such a pleasant experience that I am eager to write again. Thanks Shannon, you have been awesome!

Last but not least, I want to thank Watermark Church and the volunteers at Careers in Motion for creating the vehicle that made this book happen. I initially wrote this “book” as a public service to help unemployed professionals in the Dallas area. It was at their encouragement that I decided to publish it, and I want to give a special thanks to Martha Garza for her insistence. I have learned remarkable things can happen when you give your time to help others.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required