runtime
01 / 88

lesson 01 SQL foundations · beginner

Meet your first SELECT

Choose columns and read rows from a table.

the idea

A table is a collection of rows and named columns. SELECT chooses the columns you want to see; FROM names the table. A query reads data without changing it.

tables in this lesson

The challenges use this data. Each column shows its type underneath; → marks a link to another table.

customers4 columns · 8 rows
idinteger · keynametextcitytextjoined_attext
1AliceChicago2024-01-10
2BenAustin2024-02-12
3CaraSeattle2024-03-05
4DevChicago2024-04-20
5ElenaNULL2024-05-01

showing 5 of 8 rows

products4 columns · 6 rows
idinteger · keynametextcategorytextpricereal
1NotebookStationery12
2Desk lampHome45
3KeyboardTech80
4Pen setStationery8
5HeadphonesTech120

showing 5 of 6 rows

example

The idea in one query. Press Run to see what it returns; running examples never affects your progress.

example.sql
SELECT name, city
FROM customers;

Watch for: SELECT * includes extra columns. Return only the columns the task asks for.

build it step by step

Each step changes one thing. Run them in order and watch the result change.

  1. Start with a table. Every row is one customer. Read all columns first.

    step-1.sql
    SELECT *
    FROM customers;
  2. Choose two columns. SELECT changes the visible columns, not the underlying rows.

    step-2.sql
    SELECT name,city
    FROM customers;

challenge 1

Show the name and city of every customer.

Return namecityany row order

challenge-1.sql
 
To master this lesson, solve both challenges without hints and pass the concept check. 3 of 3 to go.