AI Hints
Homeโ€บSQL Tutorialโ€บYour First Queries
SQL ยท Lesson 4 of 126

Your First SELECT

Get every column.

โฑ 2 min readโ–ถ Video at 4:36๐ŸŽ“ Free
Watch this lesson in the SQL courseWatch on YouTube โ†—Full SQL course

Helen's first question is a simple one. Who works here? Let's answer it with the shortest query in SQL.

Your First SELECT
From the video: Your First SELECT
  • Helen's first question
  • Who works here?
  • The shortest query in SQL

Show me everything

Read this out loud. Select star, from staff. The word select means, show me. The star means, every column. And from staff says which table to look in. The semicolon at the end means, that's the end of my question. Run it. There are all eight people who work at Riverside Books, with every column.

query.sqlsql
SELECT * FROM staff;
Output
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ staff_id โ”‚    name    โ”‚      role      โ”‚ manager_id โ”‚ salary โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ 1        โ”‚ Helen Ward โ”‚ Owner          โ”‚            โ”‚ 72000  โ”‚
โ”‚ 2        โ”‚ Marcus Lee โ”‚ Store Manager  โ”‚ 1          โ”‚ 54000  โ”‚
โ”‚ 3        โ”‚ Priya Nair โ”‚ Online Manager โ”‚ 1          โ”‚ 56000  โ”‚
โ”‚ 4        โ”‚ Tom Baker  โ”‚ Bookseller     โ”‚ 2          โ”‚ 31000  โ”‚
โ”‚ 5        โ”‚ Sara Odum  โ”‚ Bookseller     โ”‚ 2          โ”‚ 32000  โ”‚
โ”‚ 6        โ”‚ Leo Grant  โ”‚ Warehouse      โ”‚ 3          โ”‚ 29000  โ”‚
โ”‚ 7        โ”‚ Amy Chen   โ”‚ Web Support    โ”‚ 3          โ”‚ 33000  โ”‚
โ”‚ 8        โ”‚ Noah Price โ”‚ Bookseller     โ”‚ 2          โ”‚ 30500  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

The two words you always need

Almost every query starts with two parts. Select says which columns you want. From says which table they come from. Select, then from. Always in that order. If you remember nothing else today, remember that.

keyvalue
SELECTwhich columns
FROMwhich table
*every column
;end of the question

Quick check

Quick check. Which query shows every column of the books table? Pause and choose. The answer is B. Select star from books. The star means every column, and from books names the table.

Quick check
Show every column of the books table

Summary

Select star, from a table, shows everything. But most of the time, you don't want everything. Let's learn to pick just the columns you need.

Key takeaways
  • SELECT shows
  • FROM names the table
  • * means every column
Next up: Choosing Columns โ€” only what you need