Your first SELECT

Stage 1: Basics · Lesson 1 of 17 · 4 min read · free, interactive

A database stores data in tables. Each table has named columns, and every row is one record — one player, one item, one match.

To read data you write a query that starts with SELECT. The simplest one asks for every column (*) of a table:

SELECT * FROM players;

Usually you only need some columns. List them after SELECT, separated by commas. The result keeps the order you wrote them in.

SELECT name, level FROM players;

A column can also be a calculation. Give it a readable name with AS — this name is called an alias.

SELECT name, level * 100 AS xp FROM players;

The table is unchanged: SELECT only reads.

Tip: SQL keywords are not case-sensitive (select works too), but writing them in capitals makes queries easier to scan.

Practice

Each answer runs in your browser and is checked on hidden data.

Next: Filtering rows with WHERE · All lessons