Module 0 · Orientation

What SQL is and what it is for

By the end you will be able to consult a table to answer a simple question.

About 8 min

0 of 52 lessons

Ask the data a question

Picture a shop that keeps a list of customers. You want to know which cities they live in without going through their records one by one. SQL lets you ask the data that question and get back a list with the answer.

SQL is a language that lets you query and modify data in a database, a collection of information stored in an organised way. Its name stands for Structured Query Language. In this course we will work with tables, which organise data into rows and columns, much like a spreadsheet.

A query is an instruction written in SQL. To read data, we will start with two words: SELECT says which information you want to see and FROM says which table it comes from. Asking for each customer's city does not change their data; it just produces a result you can read.

The data and the editor are already set up. Read the example, write your query in the practice task and press «Run and check». You do not need to install anything. Later you will learn to filter, summarise and change data, one idea at a time.

Minimal syntax
SELECT column_name
FROM table_name;

See it in action

Which cities do our customers live in?

SQL
SELECT city
FROM customers;
Example result: 8 of 12 rows
city
London
Manchester
London
Bristol
Leeds
London
Bristol
Manchester
  1. The customers table contains one row per person. FROM customers says where to look.
  2. SELECT city asks for one attribute of each person. The result keeps all twelve rows, even though some cities appear more than once.
  3. Reading a table does not change its data. You can query name instead of city to ask a different question.

Practice with help

Getting things wrong is part of learning: you can run your query as many times as you like and nothing is lost. If you get stuck, open a hint (each one reveals a bit more) and save the solution for last.

Guided practice

Look up the cities

Not started

Write a query that returns only the city column for every customer.

Expected result: 12 rows with the column city, in that order. Row order does not matter.

View tables and data

Open this panel to see the full data.

Your turn

Solve this variation. Spot the part that has changed before you look for help.

Practice

Change the question

Not started

Show only the name of every customer. Do not filter or sort the rows.

Expected result: 12 rows with the column name, in that order. Row order does not matter.

View tables and data

Open this panel to see the full data.

Key takeaways

  • SQL lets you ask questions of stored data.
  • A SELECT query returns a result.
  • FROM names the table you are querying.