sql · level 1 · unit 1 · lesson 3
- meet it
- guess first
- your turn
- fix it
- nailed it
Tap a green word if you get lost.
meet it
Name the columns you want, with commas in between.
Tables can have lots of columns, and often you need only a few. Swap the star for the names of the columns you want, with a comma between each one.
Each box where a row meets a column holds one , like Rex or 3. The you get back has your columns, in the order you listed them.
You can ask several queries in one go. Each one ends with its own semicolon, and each result appears in turn, with a blank line between.
SELECT name, age FROM pets; The commas go between the column names, never after the last one.
guess first
Two queries, two orders. What will this show?
Guess before you run it. Wrong guesses are how you learn, and nothing is marked.
SELECT dish, price FROM puddings;
SELECT price, dish FROM starters;
your turn
Your turn. Plan a snack shopping list.
The snacks table has the columns name, kind, price and stock. Pick any two and type them in the blanks, then press run.
result
Your answer appears here as a table.
fix it
The ages have gone missing. Can you fix it?
result
Your answer appears here as a table.
- Look at the top line of the result. How many columns came back?
- Without a comma, the database thinks
ageis a new label for the name column. - Put a comma after name, so it reads name, age, then press run.
nailed it
you picked exactly the columns you wanted. :D
- List column names after
SELECT, with commas between. - Columns come back in the order you list them.
- Several queries give several results, one after another.
new words in your collection
- value
- result
This lesson isn’t saved. A free account remembers every lesson you finish.