This site runs best with JavaScript enabled.Lesson 2: The SQL SELECT Statement

Lesson 2: The SQL SELECT Statement


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

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

The SELECT statement.

You dont 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 Beginners Guide To SQL though, Ill spell it out for you:

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

If youre the greedy sort (read: lazy and couldnt 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 dont care if I can carry it or how long it takes to arrive, just give it to me.

All of it from where?

We havent 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 doesnt make you take extra care around soaking it into your brain then I dont 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.



The Answer.

Correct SQL:

Correct Output:

Share lesson