So you wanna learn SQL huh? You’ve come to the right place. This interactive SQL tutorial is designed to get you querying as quickly as possible.
I think it’s best to just dive right in, but it’s going to be incredibly beneficial to go over just a few quick concepts first (trust me, we get to running your first SQL on the very next page).
SQL might seem intimidating but it’s really fairly easy to understand. SQL stands for Structured Query Language and simply put, it’s a search language for you to instruct a database about what information you’d like retrieved from it.
Just think of it as an advanced, really structured google search. For example in Google you might ask something like
And in SQL, if you had a database with that information in it, the equivalent question might be answered with something like
SELECT age FROM presidents WHERE name = 'Barack Obama';
Don’t worry about understanding the above query yet, you’ll get that in no time.
Tables - for those familiar with Excel
Databases organize data in different tables. I’m assuming that most people reading this are familiar with Excel or some other Spreadsheet software. This makes it easier to explain what a table is as a Table is basically just a Spreadsheet of data. It has columns with names of fields, and then rows holding the actual data.
In this tutorial we’ll be using an example data set that has a bunch of information on tracks, albums and artists in a music collection. Most databases architects will typically split those items into their own tables rather than group them all in one. You’ll learn all about linking them together when we get to the section on Table Relationships and JOINs.
SQLBox (Interactive Query Editor)
For this tutorial we’ve built a tool for you to run SQL commands and see the results along with each lesson. It’s a big black box like this so that you can try out each lesson, and play with other things you’re curious about along the way.
Having SQLBox means that you don’t have to spend a long time setting up your own environment just to get started. Playing with SQL and data is the best way to learn it. Try out running your first SQLBox queries by hitting “Run SQL” below.
After you run a query, a table with the results of your query will show up below it. All of the queries you run on this tutorial are being executed against a real PostgreSQL.
SQLBoxes that have a quiz to them will have a checkbox to their left. Once the answer is correct, the checkbox will be checked! Some of these will have a Hint you can view, and if you ever get really stuck feel free to email us for some help.
Let’s get started with our first tutorial on SELECTs.