Um momento
0x10Lesson 2 of 6

Read data with SELECT

Choose columns and a source table to retrieve useful records.

12 min 5-question quiz 1 code exercise
By the end of this lesson you can
  • Write a basic SELECT query and choose only the columns you need.

A SELECT query describes the values to return, and FROM names the table to read. Use explicit column names in application queries so the result stays clear when a table changes.

SQL example
1SELECT name, city
2FROM customers;
3
4SELECT order_id, total
5FROM orders;

SQL keywords are commonly written in uppercase for readability, but most database systems accept them in lowercase too. The semicolon marks the end of a statement in many SQL tools.

Key takeaways

  • Write a basic SELECT query and choose only the columns you need.

  • Use table and column names that make the query easy to read.

  • Check which rows a query affects before relying on its result.

Lesson quiz

5 questions · pass with 4 correct · up to 50 XP

Passing this quiz completes the lesson and keeps your streak going. Questions you miss come back in review sessions later.

Practice: write SQL queries

Write queries against small sample databases and run them locally in your browser. Each test starts from a fresh SQLite database.

Exercise 1

Choose the columns you need

+25 XP

Return each customer’s name and email address, ordered by customer ID. Do not include the ID in the result.

  • Names and emails
Choose the database engine used when you run tests.
Sample tables and rows

Each test rebuilds an in-memory database for the selected dialect before running your query.

sample-data.sql
CREATE TABLE customers (customer_id INTEGER PRIMARY KEY, name TEXT, email TEXT); INSERT INTO customers VALUES (2, 'Ari Chen', 'ari@example.test'), (1, 'Sam Lee', 'sam@example.test');
query.sql
Loading editor…

Using SQLite 3 (sql.js), an embedded database. Queries run locally in a worker against a fresh in-memory database for each test.

Questions about this lesson

Stuck? Ask. Figured something out? Share it. Explaining is one of the best ways to learn.

Loading posts…

Gostou da aula? 😆👍
Apoie nosso trabalho com uma doação: