SelectFromData
AnalyticsLesson 1 of 12 · 12 min

SELECT … FROM: The Two Words This Site Is Named After

Almost every question you will ever ask a database starts with the same two words: SELECT (which columns you want) and FROM (which table they live in).

They matter so much that this site is literally named after them — SelectFromData. Learn this one sentence shape and you've started every data career conversation that ever happened: select something, from the data.

In one line

SELECT picks the columns, FROM names the table. That's a complete query — everything else in SQL is refinement on top of it.

See everything first

SELECT * means "every column". It's how you take a first look at a table you've never met. Here's a small employees table — run it:

Your first query: everything in the table
Editable · runs in your browser

Five rows, four columns — the whole table. That's already a real query against a real database, running in your browser.

Now ask for just what you need

Real questions rarely need every column. Name the ones you want after SELECT, separated by commas. Run it, then try swapping the columns — ask for name, city instead:

Pick three columns — this is called projection
Editable · runs in your browser

Two things to notice:

  • The rows don't change — you get all five either way. SELECT chooses columns, never rows. (Choosing rows is the next lesson.)
  • Ask for a column that doesn't exist and you get an error, not a crash. Errors are the database talking back; read them calmly.

From practice

SELECT * is great for exploring, but in real work you name the columns you need. It makes the query faster, clearer to the next reader, and safe against someone adding a giant column to the table later. Build the habit on day one.

Your turn

Return just the name and city of every employee — nothing else.

Your turn · Exercise

Return only the name and city columns, for all employees.

The data

employees

5 rows returned

namedepartmentsalarycity
AdaEngineering62,000Antwerp
BoSales48,000Ghent
CyEngineering71,000Antwerp
DiSales52,000Bruges
EliMarketing45,000Ghent
Runs in your browser
Check yourself

What does the FROM part of a query do?


Next: SELECT chose the columns — WHERE chooses the rows. That's where queries start answering real questions.