Lesson 2: The SQL SELECT Statement

By Alan Hylands — 2 minute read

(Probably the most important data analysis lesson you will ever learn.)

In this lesson, we’ll be looking at the most fundamental of fundamentals in the world of SQL:

The SELECT statement.

You don’t have to have be a college English major to have a wild stab in the dark at what the SELECT statement does for you.

As this is the Non-Boring Beginner’s Guide To SQL though, I’ll spell it out for you:

SELECT lets you grab whatever data you want from the database.

If you’re the greedy sort (read: lazy and couldn’t be bothered making a choice) then you can use SELECT to bring back all of the fields. Like this:

SELECT *

The * essentially means give me everything.

Every little bit. All of it. The lot. The whole lot. I don’t care if I can carry it or how long it takes to arrive, just give it to me.

All of it from where?

We haven’t said where we want to get the data from however which brings us to the FROM part of the SELECT statement.

This tells the database which table you want to get the information out of.

For example,

SELECT * FROM customers;

This means give me everything (SELECT *) FROM the table called "customers".

And that, my friends, is the SELECT statement.

It will be THE single most useful and most used statement you will experience in your SQL database querying careers.

I call it the “Million Dollar Keyword” because learning how to use the SELECT statement can EASILY add a million dollars to your overall career earnings over the course of your lifetime. If that doesn’t make you take extra care around soaking it into your brain then I don’t know what will.

Remember me each time you write it. (Hopefully in a positive fashion.) It just might save your life.

Quiz Time.

The Question.

The database table below contains data about selected characters from the Marvel Cinematic Universe. If we wanted to grab ALL of the character data from the "characters" table, we would use the following query:

SELECT * FROM characters;

Type that into the editor box below and click the Run SQL button.

The Data.

The Editor.


Run SQL


Show Answer

The Answer.

Correct SQL:

                    SELECT * FROM characters;
                    

Correct Output:

Try the next lesson