Skip to content
Codewilds

Lesson 1 of 30 · Querying Basics

SQL SELECT: Your First Query

easy10 XP1 min readFree lesson

Databases keep the world's information in tables — rows and columns, like a spreadsheet. SQL (Structured Query Language) is how you ask a database questions. In the Archive Vaults you'll query the records of a fantasy realm: its heroes, guilds, quests and market.

Your first query

Every question starts with SELECT. You say what you want to see and from which table:

SELECT * FROM heroes;
  • SELECT — "show me…"
  • * — "…every column…"
  • FROM heroes — "…of the table called heroes."
  • ; ends the statement.

The database answers with a result set: a new table with the matching rows. Press Run and it appears below the editor — try it with heroes first.

The tables in this course

Every lesson uses the same database, and every run starts from a fresh copy — you can't break anything.

Table Columns
heroes id, name, class, level, gold, guild_id, joined
guilds id, name, city, founded
quests id, title, region, difficulty, reward
completions hero_id, quest_id, completed_on — which hero finished which quest
items id, name, type, price, rarity — the market
purchases id, hero_id, item_id, quantity, bought_on

Keywords and style

SQL keywords aren't case-sensitive — select * from heroes works too — but writing them in CAPITALS makes queries easier to read. Table names are usually lowercase.

Common mistakes

  • Misspelling the table name. SELECT * FROM hero; fails with no such table: hero — the table is called heroes.
  • Forgetting FROM. SELECT * on its own doesn't know where to look.

Assignment

Write a query that shows every column of every row in the guilds table.

Keep learning

Need a quick reminder? The SQL cheat sheet has every topic of Learn SQL on one page.

Lesson last updated on .

Write code ↓
SQL+10 XP

Press Run to execute your code, or Submit to check it against the tests.